/****************************************/
/* Copyright (c) 2004, 通信工程学院戴佳 */
/* All rights reserved. */
/* 作 者:戴佳 */
/****************************************/
#include <other.h>
void PolFill(struct instruction PolValue);
void AlmInd(struct instruction AlmValue);
void M1PAlmQ();
void M2PAlmQ();
void M3PAlmQ();
void M4PAlmQ();
void Alm_query()
{
struct instruction AlmVal;
struct instruction PolVal;
uchar TMP;
uchar tmp_f1=0;
uchar tmp_f2=0;
uchar tmp_f3=0;
uchar tmp_f4=0;
tmp_f1=f[0]+f[1]+f[2]+f[3]; //Mapper 1
tmp_f2=f[4]+f[5]+f[6]+f[7]; //Mapper 2
tmp_f3=f[8]+f[9]+f[10]+f[11]; //Mapper 3
tmp_f4=f[12]+f[13]+f[14]+f[15]; //Mapper 4
if ((FgADLOC==0)&&((((M1_023&0x80)==0x80)&&(tmp_f1!=0))||(((M2_023&0x80)==0x80)&&(tmp_f2!=0))
||(((M3_023&0x80)==0x80)&&(tmp_f3!=0))||(((M4_023&0x80)==0x80)&&(tmp_f4!=0)))) //ADLOC
{
FgADLOC=1;
AlmVal.head=0x08;
AlmVal.oper_obj=1;
AlmVal.ObjVal[0]=0;
AlmVal.ObjVal[1]=0xFF;
AlmInd(AlmVal);
}
else if (FgADLOC==1)
{
if (
(((M1_023&0x80)!=0x80)||(tmp_f1==0))
&&(((M2_023&0x80)!=0x80)||(tmp_f2==0))
&&(((M3_023&0x80)!=0x80)||(tmp_f3==0))
&&(((M4_023&0x80)!=0x80)||(tmp_f4==0))
)
{
FgADLOC=0;
AlmVal.head=0x08;
AlmVal.oper_obj=1;
AlmVal.ObjVal[0]=0;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
}
}
if ((FgAALOC==0)&&((((M1_023&0x40)==0x40)&&(tmp_f1!=0))||(((M2_023&0x40)==0x40)&&(tmp_f2!=0))
||(((M3_023&0x40)==0x40)&&(tmp_f3!=0))||(((M4_023&0x40)==0x40)&&(tmp_f4!=0)))) //AALOC
{
FgAALOC=1;
AlmVal.head=0x08;
AlmVal.oper_obj=1;
AlmVal.ObjVal[0]=1;
AlmVal.ObjVal[1]=0xFF;
AlmInd(AlmVal);
}
else if (FgAALOC==1)
{
if (
(((M1_023&0x40)!=0x40)||(tmp_f1==0))
&&(((M2_023&0x40)!=0x40)||(tmp_f2==0))
&&(((M3_023&0x40)!=0x40)||(tmp_f3==0))
&&(((M4_023&0x40)!=0x40)||(tmp_f4==0))
)
{
FgAALOC=0;
AlmVal.head=0x08;
AlmVal.oper_obj=1;
AlmVal.ObjVal[0]=1;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
}
}
if ((FgAUAIS==0)&&((((M1_023&0x01)==0x01)&&(tmp_f1!=0))||(((M2_023&0x01)==0x01)&&(tmp_f2!=0))
||(((M3_023&0x01)==0x01)&&(tmp_f3!=0))||(((M4_023&0x01)==0x01)&&(tmp_f4!=0)))) //A1UAISI
{
FgAUAIS=1;
PolVal.head=0x08;
PolVal.oper_obj=2;
PolVal.ObjVal[0]=0;
PolVal.ObjVal[1]=0xFF;
PolFill(PolVal);
}
else if (FgAUAIS==1)
{
if (
(((M1_023&0x01)!=0x01)||(tmp_f1==0))
&&(((M2_023&0x01)!=0x01)||(tmp_f2==0))
&&(((M3_023&0x01)!=0x01)||(tmp_f3==0))
&&(((M4_023&0x01)!=0x01)||(tmp_f4==0))
)
{
FgAUAIS=0;
PolVal.head=0x08;
PolVal.oper_obj=2;
PolVal.ObjVal[0]=0;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if ((FgADH4E=0)&&((((M1_025&0x01)==0x01)&&(tmp_f1!=0))||(((M2_025&0x01)==0x01)&&(tmp_f2!=0))
||(((M3_025&0x01)==0x01)&&(tmp_f3!=0))||(((M4_025&0x01)==0x01)&&(tmp_f4!=0)))) //A1DH4E latched
{
FgADH4E=1;
AlmVal.head=0x08;
AlmVal.oper_obj=3;
AlmVal.ObjVal[0]=0;
AlmVal.ObjVal[1]=0xFF;
AlmInd(AlmVal);
}
else if (FgADH4E==1)
{
if (
(((M1_025&0x01)!=0x01)||(tmp_f1==0))
&&(((M2_025&0x01)!=0x01)||(tmp_f2==0))
&&(((M3_025&0x01)!=0x01)||(tmp_f3==0))
&&(((M4_025&0x01)!=0x01)||(tmp_f4==0))
)
{
FgADH4E=0;
AlmVal.head=0x08;
AlmVal.oper_obj=3;
AlmVal.ObjVal[0]=0;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
}
}
WDI=1;
WDI=0;
M1PAlmQ();
M2PAlmQ();
WDI=1;
WDI=0;
M3PAlmQ();
M4PAlmQ();
WDI=1;
WDI=0;
if (FgTLOS[0]==1)
{
TMP=T1_012&0x01;
if ((f[0]==0)||(TMP==0x00)) //T1LOS
{
FgTLOS[0]=0;
AlmVal.head=0x08;
AlmVal.oper_obj=15;
AlmVal.ObjVal[0]=0;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
M1_050=M1_050&0xEF; //TnAIS=0,cancel send AIS in transmit data stream
}
}
if (FgTLOC[0]==1)
{
if (((M1_045&0x02)!=0x02)||(f[0]==0)) //T1LOC
{
FgTLOC[0]=0;
AlmVal.head=0x08;
AlmVal.oper_obj=1;
AlmVal.ObjVal[0]=16;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
}
}
if (FgAAIS[0]==1)
{
if (((M1_031&0x80)!=0x80)||(f[0]==0)) //A1AIS
{
FgAAIS[0]=0;
PolVal.head=0x08;
PolVal.oper_obj=2;
PolVal.ObjVal[0]=16;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if (FgTDAIS[0]==1)
{
if (((M1_045&0x01)!=0x01)||(f[0]==0)) //T1DAIS
{
FgTDAIS[0]=0;
PolVal.head=0x08;
PolVal.oper_obj=2;
PolVal.ObjVal[0]=48;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if (FgANDF[0]==1)
{
if (((M1_031&0x10)!=0x10)||(f[0]==0)) //A1NDF NEW POINTER IND
{
FgANDF[0]=0;
PolVal.head=0x08;
PolVal.oper_obj=6;
PolVal.ObjVal[0]=0;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if (FgARDI[0]==1)
{
if (((M1_031&0x08)!=0x08)||(f[0]==0)) //A1RDI
{
FgARDI[0]=0;
PolVal.head=0x08;
PolVal.oper_obj=7;
PolVal.ObjVal[0]=0;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if (FgAUNEQ[0]==1)
{
if (((M1_031&0x02)!=0x02)||(f[0]==0)) //A1UNEQ
{
FgAUNEQ[0]=0;
PolVal.head=0x08;
PolVal.oper_obj=9;
PolVal.ObjVal[0]=0;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if (FgASLER[0]==1)
{
if (((M1_031&0x01)!=0x01)||(f[0]==0)) //A1SLER
{
FgASLER[0]=0;
AlmVal.head=0x08;
AlmVal.oper_obj=10;
AlmVal.ObjVal[0]=0;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
}
}
if (FgAJ2TIM[0]==1)
{
if (((M1_04F&0x04)!=0x04)||(f[0]==0)) //A1J2TIM
{
FgAJ2TIM[0]=0;
AlmVal.head=0x08;
AlmVal.oper_obj=12;
AlmVal.ObjVal[0]=0;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
}
}
if (FgTLOS[1]==1)
{
TMP=T1_052&0x01;
if ((f[1]==0)||(TMP==0x00)) //T2LOS
{
FgTLOS[1]=0;
AlmVal.head=0x08;
AlmVal.oper_obj=15;
AlmVal.ObjVal[0]=1;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
M1_080=M1_080&0xEF; //TnAIS=0,cancel send AIS in transmit data stream
}
}
if (FgTLOC[1]==1)
{
if (((M1_075&0x02)!=0x02)||(f[1]==0)) //T2LOC
{
FgTLOC[1]=0;
AlmVal.head=0x08;
AlmVal.oper_obj=1;
AlmVal.ObjVal[0]=17;
AlmVal.ObjVal[1]=0;
AlmInd(AlmVal);
}
}
if (FgAAIS[1]==1)
{
if (((M1_061&0x80)!=0x80)||(f[1]==0)) //A2AIS
{
FgAAIS[1]=0;
PolVal.head=0x08;
PolVal.oper_obj=2;
PolVal.ObjVal[0]=17;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if (FgTDAIS[1]==1)
{
if (((M1_075&0x01)!=0x01)||(f[1]==0)) //T2DAIS
{
FgTDAIS[1]=0;
PolVal.head=0x08;
PolVal.oper_obj=2;
PolVal.ObjVal[0]=49;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if (FgANDF[1]==1)
{
if (((M1_061&0x10)!=0x10)||(f[1]==0)) //A2NDF
{
FgANDF[1]=0;
PolVal.head=0x08;
PolVal.oper_obj=6;
PolVal.ObjVal[0]=1;
PolVal.ObjVal[1]=0;
PolFill(PolVal);
}
}
if (FgARDI[1]==1)
{