예제 #1
0
void    ReadVersionS(void)
{
  InitPop(9);

  Clear();
  sprintf(szLo+1, "верси¤ %u.%u.%u", PopChar(), PopChar(), PopChar());
}
예제 #2
0
double2 ReadTrans31_Full(void)
{
  if (QueryOpen31_Full(25) == false) return GetDouble2Error();


  uchar r;
  for (r=0; r<MaxRepeats(); r++)
  {
    DelayOff();
    QueryTrans31();

    if (Input31() == SER_GOODCHECK) break;
    if (fKey == true) return GetDouble2Error();
  }

  if (r == MaxRepeats()) return GetDouble2Error();
  ShowPercent(50);


  InitPop(3+4+4+1);

  double dbTransU = PopDouble31();
  double dbTransI = PopDouble31();

  return GetDouble2(dbTransU*dbTransI, true);
}
예제 #3
0
void    ReadHeaderQ(uchar  ibLine)
{
  InitPop(1);

  uchar h;
  for (h=0; h<48; h++)
  {
    mpdbBuffCanHou[ibLine][h] = PopDoubleQ()/2;
  }
}
예제 #4
0
void    ReadEnergyQ(void)
{
  InitPop(1);

  uchar i;
  for (i=0; i<MAX_LINE_Q; i++)
  {
    mpdbChannelsC[i] = PopDoubleQ();
  }
}
예제 #5
0
void    ReadHeaderU_Plc(void)
{
  InitPop(1);

  uchar i;
  for (i=0; i<bPlcUSize; i++)
  {
    mpflBuffCanHou[ibMinor][i] = PopDoubleQ()/2;
  }
}
예제 #6
0
void    ReadEng34(void)
{
  InitPop(4);

  uchar i;
  for (i=0; i<MAX_LINE_N34; i++)
  {
    mpddwChannels34[i] = PopLongLtl();
    mpddwChannels34[i] += 0x100000000*PopLongLtl();
  }
}
예제 #7
0
void    ReadEnergyS(void)
{
  InitPop(9);

  coEnergy.mpbBuff[0] = PopChar();
  coEnergy.mpbBuff[1] = PopChar();
  coEnergy.mpbBuff[2] = PopChar();
  coEnergy.mpbBuff[3] = PopChar();

  mpdwChannelsA[0] = coEnergy.dwBuff;
  mpboChannelsA[0] = true;
}
예제 #8
0
void    ReadConfigS(void)
{
  InitPop(9);

  switch (PopChar() & 0x03)
  {
    case 0x00: wDividerS = 1; break;
    case 0x01: wDividerS = 10; break;
    case 0x02: wDividerS = 100; break;
    default:   wDividerS = 1000; break;
  }
}
예제 #9
0
bool    ReadKoeffDeviceG(void)
{
uchar   i;

  for (i=0; i<bMINORREPEATS; i++)
  {
    QueryOpenG();

    if (CodInput() == SER_GOODCHECK) break;
    if (fKey == true) return(0);
  }

  if (i == bMINORREPEATS) return(0);

  if (ReadOpenG() == 0) return(0);


  for (i=0; i<bMINORREPEATS; i++)
  {
    DelayOff();
    InitPushCod();

    PushChar(0x7E);
    PushChar(0x03);
    PushChar(0x06);

    PushCharCod(0x03);
    PushCharCod(0x00);
    PushCharCod(0x00);

    CodQueryIO(3+25+1, 3+3+1);

    if (CodInput() == SER_GOODCHECK) break;
    if (fKey == true) return(0);
  }

  if (i == bMINORREPEATS) return(0);
  ShowPercent(50);


  InitPop(3);
  for (i=0; i<9; i++) PopChar();

  if (ExtVersionCod()) PopRealExt_G(); else PopRealBCD_G();
  dbKtrans = reBuffA;

  if (ExtVersionCod()) PopRealExt_G(); else PopRealBCD_G();
  dbKtrans *= reBuffA;                  // K трансформации

  reBuffA = 10000;                      // K преобразования

  return(1);
}
예제 #10
0
time    ReadTimeS(void)
{
  InitPop(9);

  time ti;

  ti.bSecond = FromBCD(PopChar());
  ti.bMinute = FromBCD(PopChar());
  ti.bHour   = FromBCD(PopChar());

  PopChar();

  ti.bDay    = FromBCD(PopChar());
  ti.bMonth  = FromBCD(PopChar());
  ti.bYear   = FromBCD(PopChar());

  return ti;
}
예제 #11
0
파일: GENALG2.C 프로젝트: chrisdurtschi/ai
/* the main program: set up the population and loop through evolutionary
       cycles (generations) as controlled by the user */
main()
{
  InitPop();  /* initialize the population */

  do    /* for each evolutionary cycle */
  {
    /* reproduce, cross-over, and mutate each cycle */
    Repro();
    Cross();
    Mutate();

    /* test each individual for survivability, update goodness variables,
       and print statistics for the top genotypes */
    Test();
    Top(NTop);
  } while (More());

  return 0;
}
예제 #12
0
bool    ReadCntMonCanF_Curr(uchar  ibMon, uchar  ibCan)
{
  Clear();

  LoadCurrDigital(ibCan);
  ibPort = diCurr.ibPort;

  uchar i;
  for (i=0; i<bMINORREPEATS; i++)
  {
    QueryBreakF();

    InitPushPck();
    PushChar(diCurr.bAddress);          
    PushChar(0);

    PushChar((5+3+2) % 0x100);
    PushChar((5+3+2) / 0x100);

    PushChar(0xFD);
    PushChar(bEXT_GETEXTENDED42);         
    PushChar(ibMon);         
    PushChar(ibCan);         

    PckQueryIO(bHEADER+(1+2+2+8+6)+2, 5+3+2);

    if (Input() == SER_GOODCHECK) break;
    if (fKey == true) return false;
  }

  if (i == bMINORREPEATS) return false;
  ShowPercent(100);


  InitPop(bHEADER);
  bStatus4 = PopChar();
  PopChar(); PopChar();
  PopChar(); PopChar();
  dbValue4 = PopDouble();
  Pop(&tiUpdate4, sizeof(time));

  return true;
}
예제 #13
0
static bool ReadDataS(uchar  i)
{
  sprintf(szLo," %02u    %02u.%02u.%02u", tiDig.bHour, tiDig.bDay,tiDig.bMonth,tiDig.bYear);

  if (SearchDefHouIndex(tiDig) == 0) return(1);


  ShowProgressDigHou();

  InitPop(9+i*3);

  ulong dw = PopChar();
  dw += PopChar()*0x100;
  dw += PopChar()*0x10000;

  if (dw != 0xFFFFFF)
  {
    double dbPulse = mpdbPulseHou[ibDig];

    double db = (double)dw/wDividerS;
    mpdbEngFrac[ibDig] += db;

    uint w;
    if ((ulong)(mpdbEngFrac[ibDig]*dbPulse) < 0xFFFF)
    { w = (uint)(mpdbEngFrac[ibDig]*dbPulse); }
    else
    { w = 0xFFFF; mpcwOverflowHhr[ibDig]++; }

    mpwChannels[0] = w;
    mpdbEngFrac[ibDig] -= (double)w/dbPulse;

    MakeSpecial(tiDig);
    return(MakeStopHou(0));
  }
  else
  {
    szLo[15] = '*';
    return(MakeStopHou(0));
  }
}
예제 #14
0
void    UnpackW(bool  fShow, uchar  bOffset)
{
  if (cbHeaderBcc == 0) return;

  if (cwInBuffBcc == IndexInBuff()) return;
  cwInBuffBcc = IndexInBuff();

  if ((fShow == true) && (IndexInBuff() > 60)) sprintf(szLo," прием: %-4u    ",IndexInBuff());

  if (IndexInBuff() > 2)
  {
    InitPop(1);

    uint j = 0;

    uchar i;
    for (i=0; i<IndexInBuff()-2; i++)
    {
      if (PopChar0Bcc() == ')') j++;

//      MonitorString("\n"); MonitorCharDec(j); MonitorString(" ? "); MonitorCharDec(cbHeaderBcc);
//      MonitorString(" "); MonitorCharDec(i); MonitorString(" + "); MonitorCharDec(bOffset); MonitorString(" ? "); MonitorCharDec(IndexInBuff());

      if ((j == cbHeaderBcc) && (i+bOffset == IndexInBuff()) && (InBuff(IndexInBuff()-2) == 0x03))
      {
        SetCountInBuff(i+bOffset);

        if ((fShow == true) && (IndexInBuff() > 60)) sprintf(szLo," прием: %-4u    ",IndexInBuff());

        MonitorIn();

        InputMode();
        mpSerial[ibPort] = SER_POSTINPUT_MASTER;
        break;
      }
    }
  }
}
예제 #15
0
void    InitPopCod(void)
{
  InitPop(3);
  ibCoder = 0;
}
예제 #16
0
// задание параметров для сумматора СЭМ-2
bool    AutomaticE(void)
{
uchar   i;

  if (OpenDeviceE() == 0) return(0);


  for (i=0; i<bMINORREPEATS; i++)
  {
    InitPush(0);
    PushChar(0x1B);
    PushChar('w');

    Query(300+1, 2, 1);

    if (EscInput() == SER_GOODCHECK) break;
    if (fKey == true) return(0);
  }

  if (i == bMINORREPEATS) return(0);
  ShowPercent(75);


  InitPop((uint)132 + diCurr.ibLine*3);// K трансформации
  PopRealBCD();

  dbKtrans = reBuffA;


  InitPop((uint)180 + diCurr.ibLine*3); // K преобразования
  PopRealBCD();

  SetCanalsAll();                        // сохранение К преобразования и К трасформации


  DelayOff();

  for (i=0; i<bMINORREPEATS; i++)       // чтение накопленной энергии
  {
    InitPush(0);
    PushChar(0x1B);
    PushChar('S');

    Query(64+1, 2, 1);

    if (EscInput() == SER_GOODCHECK) break;
    if (fKey == true) return(0);
  }

  if (i == bMINORREPEATS) return(0);
  ShowPercent(100);


  InitPop(diCurr.ibLine*4);

  coFloat.mpbBuff[0] = PopChar();
  coFloat.mpbBuff[1] = PopChar();
  coFloat.mpbBuff[2] = PopChar();
  coFloat.mpbBuff[3] = PopChar();

  ToReal();
  SetCanReal(mpreCount,ibDig);            // сохранение показаний счётчиков


  return(1);
}
예제 #17
0
void    ReadEventsA(uchar  ibEvent)
{
uchar j;
ulong dwCurr, dwPrev;
 
  ShowEventsA(ibEvent);

  if (QueryOpenA_Full(25) == 0) { bEventCode = 0; AddImpRecord(EVE_EVENTS_BADLINK); return; }

  uchar i;
  for (i=0; i<10; i++)
  {
    if (QueryEventA_Full(ibEvent,i,50) == 0) {  bEventCode = i+1; AddImpRecord(EVE_EVENTS_BADLINK); return; }

    InitPop(1);
    mptiEventAB1[i] = ReadEventA();
    mptiEventAB2[i] = ReadEventA();
  } 

  switch (ibEvent) {
    case 1: dwPrev = mpdwEventDevice[ibDig]; break;
    case 7: dwPrev = mpdwEventPhase1[ibDig]; break;
    case 8: dwPrev = mpdwEventPhase2[ibDig]; break;
    case 9: dwPrev = mpdwEventPhase3[ibDig]; break;
  }

  dwCurr = 0;
  bool f = false;

  for (i=0; i<10; i++)
  {
    time ti = mptiEventAB1[i];
    if (dwPrev == DateToEventIndex(ti)) f = true;
    if (dwCurr < DateToEventIndex(ti))
    {
      dwCurr = DateToEventIndex(ti);
      j = i;
    }

    ti = mptiEventAB2[i];
    if (dwPrev == DateToEventIndex(ti)) f = true;
    if (dwCurr < DateToEventIndex(ti))
    {
      dwCurr = DateToEventIndex(ti);
      j = i;
    }
  }

  if (dwCurr == 0) AddImpRecord(EVE_EVENTS_BADDATA);
  if ((f == false) && (mpfEventStart[ibDig] == true)) { bEventCode = GetEventCodeA(ibEvent); AddImpRecord(EVE_EVENTS_OMISSION); }

  for (i=0; i<10; i++)
  {
    uchar k = (10 + j + i + 1) % 10;

    time ti = mptiEventAB1[k];
    if (dwPrev < DateToEventIndex(ti))
    {
      tiRecordTime = ti;
      bEventCode = GetEventCodeA(ibEvent) | 0x80; // внимание !
      AddImpRecord(EVE_EVENTS_A);
    }

    ti = mptiEventAB2[k];
    if (dwPrev < DateToEventIndex(ti))
    {
      tiRecordTime = ti;
      bEventCode = GetEventCodeA(ibEvent);
      AddImpRecord(EVE_EVENTS_A);
    }
  }   

  switch (ibEvent) {
    case 1: mpdwEventDevice[ibDig] = dwCurr; SaveCache(&chEventDevice); break;
    case 7: mpdwEventPhase1[ibDig] = dwCurr; SaveCache(&chEventPhase1); break;
    case 8: mpdwEventPhase2[ibDig] = dwCurr; SaveCache(&chEventPhase2); break;
    case 9: mpdwEventPhase3[ibDig] = dwCurr; SaveCache(&chEventPhase3); break;
  }
}
예제 #18
0
bool    ReadHeaderBNew(uchar  ibBlock, bool  fDelay)
{
	HideCurrTime(1);

  InitPop((uint)(1+(16-ibBlock)*15));

  PopChar();
  tiDig.bHour   = FromBCD(PopChar());                   // врем¤/дата часового блока
  tiDig.bMinute = FromBCD(PopChar());
  tiDig.bDay    = FromBCD(PopChar());
  tiDig.bMonth  = FromBCD(PopChar());
  tiDig.bYear   = FromBCD(PopChar());

  if ((tiDig.bHour   == 0) &&                           // обрабатываем пустой блок
      (tiDig.bMinute == 0) &&
      (tiDig.bDay    == 0) &&
      (tiDig.bMonth  == 0) &&
      (tiDig.bYear   == 0))
  {
    if (++iwMajor > GetMaxShutdown()) return(0);
    sprintf(szLo," выключено: %-4u   ",iwMajor); if (fDelay == 1) DelayOff();

    if (iwDigHou != 0)
    {
       iwDigHou = (wHOURS+iwDigHou-1)%wHOURS;

       ShowProgressDigHou();
       return(MakeStopHou(0));
    }
    else return(1);
  }


  if ((tiDig.bDay   == tiSummer.bDay) &&
      (tiDig.bMonth == tiSummer.bMonth))
  {
    if ((tiDig.bHour   == 3) &&
        (tiDig.bMinute == 0))
    {
      tiDig.bHour   = 2;
      tiDig.bMinute = 0;
    }
  }


  sprintf(szLo," %02u    %02u.%02u.%02u", tiDig.bHour, tiDig.bDay,tiDig.bMonth,tiDig.bYear);

  if ((tiDig.bMinute % 30) != 0)                        // обрабатываем неполный получасовой блок
  {
    tiDig.bMinute = (tiDig.bMinute / 30)*30;
    if (SearchDefHouIndex(tiDig) == 0) { szLo[4] = '?'; if (fDelay == 1) DelayOff(); return(1); }

    iwDigHou = (wHOURS+iwDigHou+1)%wHOURS;
  }
  else if (SearchDefHouIndex(tiDig) == 0) { szLo[4] = '?'; if (fDelay == 1) DelayOff(); return(1); }


  iwMajor = 0;                                          // обнул¤ем счЄтчик после получени¤ правильных данных


  iwDigHou = (wHOURS+iwDigHou-1)%wHOURS;                // врем¤ записи должно соответсвовать началу получасового блока

  ulong dw = DateToHouIndex(tiCurr);
  dw -= (wHOURS + iwHardHou - iwDigHou) % wHOURS;
  time ti = HouIndexToDate(dw);


  ShowProgressDigHou();
  if (fDelay == 1) DelayOff();

  PopChar();

  uchar i;
  for (i=0; i<4; i++)
  {
    uint w = PopChar();
    w     += PopChar()*0x100;

    if (w == 0xFFFF) w = 0;
    mpwChannels[i] = w;
  }

  MakeSpecial(ti);
  return(MakeStopHou(0));
}