Лампа "высокое" управляется по CAN
This commit is contained in:
@@ -37,27 +37,27 @@ void timer_Init()
|
||||
IER |= M_INT13;
|
||||
}
|
||||
|
||||
int Isit(int num, int i)
|
||||
int Isit(int num, int i, int z)
|
||||
{
|
||||
int res, pls;
|
||||
|
||||
if((num<0)||(num>=0x80)) return 0;
|
||||
res = Maska[0][num/0x10]; if(i)
|
||||
res|= Maska[1][num/0x10];
|
||||
res = Maska[i][num/0x10];
|
||||
res &= (1<<(num&0x0F));
|
||||
|
||||
pls = (espero[num]>CanRestart[i]/3);
|
||||
|
||||
pls = pls || county[num];
|
||||
|
||||
res = res && pls;
|
||||
if(z) // äàííûå ðåàëüíî èçìåíèëèñ
|
||||
{
|
||||
pls = (espero[num]>CanRestart[i]/2);
|
||||
pls = pls || county[num];
|
||||
res = res && pls;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
int i,j,n,mask,qua;
|
||||
int i,j,n,z,mask,qua;
|
||||
static int rscount, cancount[2]={1,2},cancell[2]={0,0},candid[2]={0,0};
|
||||
static unsigned int masca[8], presbyt;
|
||||
|
||||
@@ -115,6 +115,8 @@ void main()
|
||||
LastMode = Mode;
|
||||
Protokol = PROTOKOL;
|
||||
|
||||
for(i=0;i<0x80;i++)
|
||||
county[i]=1;
|
||||
for(i=0;i<8;i++)
|
||||
masca[i]=0;
|
||||
for(i=0;i<2;i++)
|
||||
@@ -144,6 +146,7 @@ void main()
|
||||
|
||||
for(i=0;i<2;i++)
|
||||
if(cancount[i]) cancount[i]--;
|
||||
else cancell[i] = 0;
|
||||
}
|
||||
|
||||
for(i=0;i<2;i++)
|
||||
@@ -152,14 +155,15 @@ void main()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
|
||||
if( cancell[i]>= 0x80)
|
||||
{ cancell[i]=0;
|
||||
|
||||
if( candid[i])
|
||||
{ candid[i]=0;
|
||||
CanCycle[i]++;
|
||||
cancount[i] = CanWait[i];
|
||||
continue;
|
||||
cancount[i] += CanWait[i];
|
||||
goto Next;
|
||||
} }
|
||||
|
||||
mask = Maska[i][cancell[i]/0x10] >> (cancell[i]&0x0F);
|
||||
@@ -173,23 +177,33 @@ void main()
|
||||
break;
|
||||
} }
|
||||
|
||||
z=1;
|
||||
if(espero[cancell[i]]>CanRestart[i])
|
||||
county[cancell[i]]=1;
|
||||
{
|
||||
county[cancell[i]]=1;
|
||||
z=0;
|
||||
}
|
||||
|
||||
n=1;
|
||||
if( (Desk==dsk_COMM)||(Desk==dsk_BKSD) )
|
||||
if(cancell[i]>=start_data)
|
||||
if(cancell[i]<=start_hi_edge)
|
||||
if(sens_type[cancell[i]-start_data]>=TERMO_AD)
|
||||
n=5;
|
||||
|
||||
if(abs(modbus[cancell[i]]-archiv[cancell[i]])>=n)
|
||||
|
||||
county[cancell[i]] = (cancell[i]==keys) ? CanRepeat:1;
|
||||
{
|
||||
if(cancell[i]==keys)
|
||||
for(j=0;j<CanRptLen;j++)
|
||||
county[cancell[i]+j] = CanRptVez;
|
||||
else
|
||||
county[cancell[i]] = 1;
|
||||
}
|
||||
|
||||
if (county[cancell[i]])
|
||||
{
|
||||
for(j= 3; j>0 && !Isit(cancell[i]+j,i); j--);
|
||||
for(n=j-3; n<0 && !Isit(cancell[i]+n,i); n++);
|
||||
for(j= 3; j>0 && !Isit(cancell[i]+j,i,z); j--);
|
||||
for(n=j-3; n<0 && !Isit(cancell[i]+n,i,1); n++);
|
||||
|
||||
qua = 1 + j - n;
|
||||
cancell[i]+= n;
|
||||
@@ -197,8 +211,9 @@ void main()
|
||||
for(j=0;j<qua;j++)
|
||||
{
|
||||
n=cancell[i]+j;
|
||||
archiv[n]= modbus[n];
|
||||
espero[n]=0;
|
||||
|
||||
archiv[n]= modbus[n]; espero[n]= 0;
|
||||
if( county[n])
|
||||
{ county[n]--;
|
||||
if(!county[n] && n != cancyclo+i) candid[i]=1;
|
||||
@@ -219,12 +234,15 @@ void main()
|
||||
CanRound[i]++;
|
||||
}
|
||||
|
||||
if( Cancount[i]>1)
|
||||
if(!cancount[!i])
|
||||
cancount[!i]=1; // ÷òîáû íå ñðàçó
|
||||
}
|
||||
else cancell[i]++;
|
||||
else cancell[i]++;
|
||||
}
|
||||
|
||||
Next:
|
||||
|
||||
get_Buttons();
|
||||
|
||||
if(cDefParam)
|
||||
@@ -251,8 +269,11 @@ void main()
|
||||
calc_sensor_koef();
|
||||
}
|
||||
|
||||
if(WAKE) bTermoCal=0;
|
||||
if(!bTermoCal & presbyt) cSaveParam=1;
|
||||
if(!bTermoCal & presbyt)
|
||||
{
|
||||
cSaveParam = 1;
|
||||
cCanReset = 1;
|
||||
}
|
||||
presbyt = bTermoCal;
|
||||
|
||||
if(cCanReset)
|
||||
|
||||
Reference in New Issue
Block a user