示例#1
0
void addtraverse(node *p, node *q, boolean contin)
{ /* traverse through a tree, finding best place to add p */
  insert_(p, q);
  numtrees++;
  if (evaluate(&curtree) > bestree.likelihood) {
    copy_(&curtree, &bestree);
    addwhere = q;
  }
  copy_(&priortree, &curtree);
  if (!q->tip && contin) {
    addtraverse(p, q->next->back, contin);
    addtraverse(p, q->next->next->back, contin);
  }
}  /* addtraverse */
示例#2
0
void addtraverse(node *p, node *q, boolean contin, long *numtrees,
			boolean *succeeded)
{
 /* traverse through a tree, finding best place to add p */
  insert_(p, q, true);
  (*numtrees)++;
  if (evaluate(&curtree) > bestree.likelihood){
    copy_(&curtree, &bestree);
    (*succeeded)=true;
  }
  copy_(&priortree, &curtree);
  if (!q->tip && contin) {
    addtraverse(p, q->next->back, contin,numtrees,succeeded);
    addtraverse(p, q->next->next->back, contin,numtrees,succeeded);
  }
}  /* addtraverse */
示例#3
0
void rearrange(node *p)
{ /* rearranges the tree locally */
  node *q, *r;

  if (!p->tip && !p->back->tip) {
    r = p->next->next;
    re_move(&r, &q );
    copy_(&curtree, &priortree);
    addtraverse(r, q->next->back, false);
    addtraverse(r, q->next->next->back, false);
    copy_(&bestree, &curtree);
  }
  if (!p->tip) {
    rearrange(p->next->back);
    rearrange(p->next->next->back);
  }
}  /* rearrange */
ptr ROU63_dup_(ptr self__)
{
   ptr res__ = 0;

   res__ = (ptr)copy_(self__,0);

   ret0__:
   return (res__);
}
示例#5
0
Tensor pin_memory(const Tensor& self) {
  if (self.type().backend() != kCPU) {
    AT_ERROR("cannot pin '", self.type().toString(), "' only CPU memory can be pinned");
  }
  auto allocator = std::unique_ptr<Allocator>(new PinnedMemoryAllocator());
  auto tensor = self.type().tensorWithAllocator(self.sizes(), self.strides(), std::move(allocator));
  tensor.copy_(self);
  return tensor;
}
ptr TYP114_dup_(ptr self__)
{
   ptr res__ = 0;

   res__ = (ptr)copy_(self__,1);

   ret0__:
   return (res__);
}
示例#7
0
文件: fitch.c 项目: raeece/svamp
void rearrange(node *p, long *numtrees, long *nextsp, boolean *succeeded)
{
  node *q, *r;
  if (!p->tip && !p->back->tip) {
    r = p->next->next;
    re_move(&r, &q);
    copy_(&curtree, &priortree);
    addtraverse(r, q->next->back, false, numtrees,succeeded);
    addtraverse(r, q->next->next->back, false, numtrees,succeeded);
    copy_(&bestree, &curtree);
    if (global && ((*nextsp) == spp)) {
      putchar('.');
      fflush(stdout);
    }
  }
  if (!p->tip) {
    rearrange(p->next->back, numtrees,nextsp,succeeded);
    rearrange(p->next->next->back, numtrees,nextsp,succeeded);
  }
}  /* rearrange */
/*imprime la linea de entrada mas larga*/
main()
{
	int len;		/*longitud actual de la linea*/
	int max;		/*maxima longitud vista hasta el momento*/
	char line[MAXLINE];	/*LINEA DE ENTRADA ACTUAL*/
	char longest[MAXLINE];	/*LA LINEA MAS LARGA SE GUARDA AQUI*/
	
	max=0;
	while ((len=getline_(line,MAXLINE))>0){
	
		if (len>max){
			max=len;
			copy_(longest,line);
		}
	}
	if(max>0)		/*hubo una linea*/
		printf("%s",longest);
	return 0;
	
}
示例#9
0
void globrearrange() 
{ /* does global rearrangements */
  tree globtree;
  tree oldtree;
  int i,j,k,num_sibs,num_sibs2;
  node *where,*sib_ptr,*sib_ptr2;
  double oldbestyet = curtree.likelihood;
  int success = false;
 
  alloctree(&globtree.nodep,nonodes2);
  alloctree(&oldtree.nodep,nonodes2);
  setuptree(&globtree,nonodes2);
  setuptree(&oldtree,nonodes2);
  allocview(&oldtree, nonodes2, totalleles);
  allocview(&globtree, nonodes2, totalleles);
  copy_(&curtree,&globtree);
  copy_(&curtree,&oldtree);
  for ( i = spp ; i < nonodes2 ; i++ ) {
    num_sibs = count_sibs(curtree.nodep[i]);
    sib_ptr  = curtree.nodep[i];
    if ( (i - spp) % (( nonodes2 / 72 ) + 1 ) == 0 )
      putchar('.');
    fflush(stdout);
    for ( j = 0 ; j <= num_sibs ; j++ ) {
      re_move(&sib_ptr,&where);
      copy_(&curtree,&priortree);
      
      if (where->tip) {
        copy_(&oldtree,&curtree);
        copy_(&oldtree,&bestree);
        sib_ptr = sib_ptr->next;
        continue;
      }
      else num_sibs2 = count_sibs(where);
      sib_ptr2 = where;
      for ( k = 0 ; k < num_sibs2 ; k++ ) {
        addwhere = NULL;
        addtraverse(sib_ptr,sib_ptr2->back,true);
        if ( addwhere && where != addwhere && where->back != addwhere
              && bestree.likelihood > globtree.likelihood) {
            copy_(&bestree,&globtree);
            success = true;
        }
        sib_ptr2 = sib_ptr2->next;
      } 
      copy_(&oldtree,&curtree);
      copy_(&oldtree,&bestree);
      sib_ptr = sib_ptr->next;
    }
  }
  copy_(&globtree,&curtree);
  copy_(&globtree,&bestree);
  if (success && globtree.likelihood > oldbestyet)  {
    succeeded = true;
  }
  else  {
    succeeded = false;
  }
  freeview(&oldtree, nonodes2);
  freeview(&globtree, nonodes2);
  freetree(&globtree.nodep,nonodes2);
  freetree(&oldtree.nodep,nonodes2);
}
示例#10
0
void maketree()
{ /* construct the tree */
  long i;

  if (usertree) {
    /* Open in binary: ftell() is broken for UNIX line-endings under WIN32 */
    openfile(&intree,INTREE,"input tree file", "rb",progname,intreename);
    numtrees = countsemic(&intree);
    if(numtrees > MAXSHIMOTREES)
      shimotrees = MAXSHIMOTREES;
    else
      shimotrees = numtrees;
    if (numtrees > 2)
      initseed(&inseed, &inseed0, seed);
    if (treeprint) {
      fprintf(outfile, "User-defined tree");
      if (numtrees > 1)
        putc('s', outfile);
      putc('\n', outfile);
    }
    setuptree(&curtree, nonodes2);
    for (which = 1; which <= spp; which++)
      inittip(which, &curtree);
    which = 1;
    while (which <= numtrees) {
      for (i = 0 ; i < nonodes2 ; i++) {
        if ( i > spp) {
          /* must do this since not all nodes may be used if an 
             unrooted tree is read in after a rooted one */
          curtree.nodep[i]->back = NULL;
          curtree.nodep[i]->next->back = NULL;
          curtree.nodep[i]->next->next->back = NULL;
        }
        else curtree.nodep[i]->back = NULL;
      }
      treeread2 (intree, &curtree.start, curtree.nodep,
        lengths, &trweight, &goteof, &haslengths, &spp,false,nonodes2);
      curtree.start = curtree.nodep[outgrno - 1]->back;
      treevaluate();
      printree();
      summarize();
      which++;
    }
    FClose(intree);
    if (numtrees > 1 && loci > 1 ) {
      weight = (long *)Malloc(loci*sizeof(long));
      for (i = 0; i < loci; i++)
        weight[i] = 1;
      standev2(numtrees, maxwhich, 0, loci-1, maxlogl, l0gl, l0gf, seed);
      free(weight);
      fprintf(outfile, "\n\n");
    }
  } else { /* if ( !usertree ) */
    if (jumb == 1) {
      setuptree(&curtree, nonodes2);
      setuptree(&priortree, nonodes2);
      setuptree(&bestree, nonodes2);
      if (njumble > 1) 
        setuptree(&bestree2, nonodes2);
    }
    for (i = 1; i <= spp; i++)
      enterorder[i - 1] = i;
    if (jumble)
      randumize(seed, enterorder);
    nextsp = 3;
    buildsimpletree(&curtree);
    curtree.start = curtree.nodep[enterorder[0] - 1]->back;
    if (jumb == 1) numtrees = 1;
    nextsp = 4;
    if (progress) {
      printf("Adding species:\n");
      writename(0, 3, enterorder);
#ifdef WIN32
      phyFillScreenColor();
#endif
    }
    while (nextsp <= spp) {
      buildnewtip(enterorder[nextsp - 1], &curtree, nextsp);
      copy_(&curtree, &priortree);
      bestree.likelihood = -DBL_MAX;
      addtraverse(curtree.nodep[enterorder[nextsp - 1] - 1]->back,
                  curtree.start, true );
      copy_(&bestree, &curtree);
      if (progress) {
        writename(nextsp - 1, 1, enterorder);
#ifdef WIN32
        phyFillScreenColor();
#endif
      }
      if (global && nextsp == spp) {
        if (progress) {
          printf("\nDoing global rearrangements\n");
          printf("  !");
          for (i = 1; i <= spp - 2; i++)
            if ( (i - spp) % (( nonodes2 / 72 ) + 1 ) == 0 )
              putchar('-');
          printf("!\n");
          printf("   ");
        }
      }
      succeeded = true;
      while (succeeded) {
        succeeded = false;
        if ( global && nextsp == spp )
          globrearrange();
        else 
          rearrange(curtree.start);
        if (global && nextsp == spp)
          putc('\n', outfile);
      }
      if (global && nextsp == spp && progress)
        putchar('\n');
      if (njumble > 1) {
        if (jumb == 1 && nextsp == spp)
          copy_(&bestree, &bestree2);
        else if (nextsp == spp) {
          if (bestree2.likelihood < bestree.likelihood)
            copy_(&bestree, &bestree2);
        }
      }
      if (nextsp == spp && jumb == njumble) {
        if (njumble > 1) copy_(&bestree2, &curtree);
        curtree.start = curtree.nodep[outgrno - 1]->back;
        printree();
        summarize();
      }
      nextsp++;
    }
  }
  if ( jumb < njumble)
    return;
  if (progress) {
    printf("\nOutput written to file \"%s\"\n", outfilename);
    if (trout)
      printf("\nTree also written onto file \"%s\"\n", outtreename);
  }
  freeview(&curtree, nonodes2);
  if (!usertree) {
    freeview(&bestree, nonodes2);
    freeview(&priortree, nonodes2);
  }
  for (i = 0; i < spp; i++)
    free(x[i]);
  if (!contchars) {
    free(locus);
    free(pbar);
  }
}  /* maketree */
示例#11
0
void maketree()
{
  /* contruct the tree */
  long nextsp,numtrees;
  boolean succeeded=false;
  long i, j, which;

  if (usertree) {
    inputdata(replicates, printdata, lower, upper, x, reps);
    setuptree(&curtree, nonodes2);
    for (which = 1; which <= spp; which++)
      setuptipf(which, &curtree);
    if (eoln(infile)) {
      fscanf(infile, "%*[^\n]");
      getc(infile);
    }
    openfile(&intree,INTREE,"input tree file","r",progname,intreename);
    fscanf(intree, "%ld%*[^\n]", &numtrees);
    getc(intree);
    if (numtrees > MAXNUMTREES) {
      printf("\nERROR: number of input trees is read incorrectly from %s\n",
        intreename);
      exxit(-1);
    }
    if (treeprint) {
      fprintf(outfile, "User-defined tree");
      if (numtrees > 1)
        putc('s', outfile);
      fprintf(outfile, ":\n\n");
    }
    first = true;
    which = 1;
    while (which <= numtrees) {
      treeread2 (intree, &curtree.start, curtree.nodep,
        lengths, &trweight, &goteof, intreename, "Fitch",
        &haslengths, &spp);
      nums = spp;
      curtree.start = curtree.nodep[outgrno - 1]->back;
      treevaluate();
      printree(&curtree, curtree.start, treeprint, false, false);
      summarize(numtrees);
      which++;
    }
    FClose(intree);
  } else {
    if (jumb == 1) {
      inputdata(replicates, printdata, lower, upper, x, reps);
      setuptree(&curtree, nonodes2);
      setuptree(&priortree, nonodes2);
      setuptree(&bestree, nonodes2);
      if (njumble > 1) setuptree(&bestree2, nonodes2);
    }
    for (i = 1; i <= spp; i++)
      enterorder[i - 1] = i;
    if (jumble)
      randumize(seed, enterorder);
    nextsp = 3;
    buildsimpletree(&curtree, nextsp);
    curtree.start = curtree.nodep[enterorder[0] - 1]->back;
    if (jumb == 1) numtrees = 1;
    nextsp = 4;
    if (progress) {
      printf("Adding species:\n");
      writename(0, 3, enterorder);
#ifdef WIN32
      phyFillScreenColor();
#endif
    }
    while (nextsp <= spp) {
      nums = nextsp;
      buildnewtip(enterorder[nextsp - 1], &curtree, nextsp);
      copy_(&curtree, &priortree);
      bestree.likelihood = -99999.0;
      addtraverse(curtree.nodep[enterorder[nextsp - 1] - 1]->back,
                  curtree.start, true, &numtrees,&succeeded);
      copy_(&bestree, &curtree);
      if (progress) {
        writename(nextsp  - 1, 1, enterorder);
#ifdef WIN32
        phyFillScreenColor();
#endif
      }
      if (global && nextsp == spp) {
        if (progress) {
          printf("Doing global rearrangements\n");
          printf("  !");
          for (j = 1; j <= (spp - 2); j++)
            putchar('-');
          printf("!\n");
          printf("   ");
        }
      }
      succeeded = true;
      while (succeeded) {
        succeeded = false;
        rearrange(curtree.start,
                  &numtrees,&nextsp,&succeeded);
        if (global && ((nextsp) == spp) && progress)
          printf("\n   ");
      }
      if (global && nextsp == spp) {
        putc('\n', outfile);
        if (progress)
          putchar('\n');
      }
      if (njumble > 1) {
        if (jumb == 1 && nextsp == spp)
          copy_(&bestree, &bestree2);
        else if (nextsp == spp) {
          if (bestree2.likelihood < bestree.likelihood)
            copy_(&bestree, &bestree2);
        }
      }
      if (nextsp == spp && jumb == njumble) {
        if (njumble > 1) copy_(&bestree2, &curtree);
        curtree.start = curtree.nodep[outgrno - 1]->back;
        printree(&curtree, curtree.start, treeprint, true, false);
        summarize(numtrees);
      }
      nextsp++;
    }
  }
  if (jumb == njumble && progress) {
    printf("\nOutput written to output file\n\n");
    if (trout) {
      printf("Tree also written onto file\n");
      putchar('\n');
    }
  }
}  /* maketree */
示例#12
0
文件: main.cpp 项目: hirakuni45/RX
int main(int argc, char** argv)
{
	device::PORT3::PCR.B5 = 1; // P35(NMI) pull-up

	device::PORT0::PDR.B5 = 1;  // (2)
	device::PORT0::PDR.B2 = 1;  // (6)
	device::PORT0::PDR.B1 = 1;  // (7)
	device::PORT0::PDR.B0 = 1;  // (8)
	device::PORTJ::PDR.B5 = 1;  // (11)
	device::PORTJ::PDR.B3 = 1;  // (13)

	device::PORT3::PDR.B3 = 1;  // (26)
	device::PORT3::PDR.B2 = 1;  // (27)

	device::PORT2::PDR.B5 = 1;  // (32)
	device::PORT2::PDR.B4 = 1;  // (33)
	device::PORT2::PDR.B3 = 1;  // (34)
	device::PORT2::PDR.B2 = 1;  // (35)
	device::PORT2::PDR.B1 = 1;  // (36)
	device::PORT2::PDR.B0 = 1;  // (37)
	device::PORT1::PDR.B7 = 1;  // (38)
	device::PORT8::PDR.B7 = 1;  // (39)

	device::PORT8::PDR.B6 = 1;  // (41)
	device::PORT1::PDR.B5 = 1;  // (42)
	device::PORT1::PDR.B4 = 1;  // (43)
	device::PORT1::PDR.B3 = 1;  // (44)
	device::PORT1::PDR.B2 = 1;  // (45)

	device::PORT5::PDR.B6 = 1;  // (50)
	device::PORT5::PDR.B5 = 1;  // (51)
	device::PORT5::PDR.B4 = 1;  // (52)

	device::PORT5::PDR.B2 = 1;  // (54)
	device::PORT5::PDR.B1 = 1;  // (55)
	device::PORT5::PDR.B0 = 1;  // (56)

	device::PORT8::PDR.B3 = 1;  // (58)

	device::PORTC::PDR.B6 = 1;  // (61)
	device::PORTC::PDR.B5 = 1;  // (62)
	device::PORT8::PDR.B2 = 1;  // (63)
	device::PORT8::PDR.B1 = 1;  // (64)
	device::PORT8::PDR.B0 = 1;  // (65)
	device::PORTC::PDR.B4 = 1;  // (66)
	device::PORTC::PDR.B3 = 1;  // (67)
	device::PORT7::PDR.B7 = 1;  // (68)
	device::PORT7::PDR.B6 = 1;  // (69)
	device::PORTC::PDR.B2 = 1;  // (70)
	device::PORT7::PDR.B5 = 1;  // (71)
	device::PORT7::PDR.B4 = 1;  // (72)
	device::PORTC::PDR.B1 = 1;  // (73)

	device::PORTC::PDR.B0 = 1;  // (75)
	device::PORT7::PDR.B3 = 1;  // (77)
	device::PORTB::PDR.B7 = 1;  // (78)
	device::PORTB::PDR.B6 = 1;  // (79)
	device::PORTB::PDR.B5 = 1;  // (80)
	device::PORTB::PDR.B4 = 1;  // (81)

	device::PORTB::PDR.B2 = 1;  // (83)
	device::PORTB::PDR.B1 = 1;  // (84)
	device::PORT7::PDR.B2 = 1;  // (85)
	device::PORT7::PDR.B1 = 1;  // (86)
	device::PORTB::PDR.B0 = 1;  // (87)

	device::PORTA::PDR.B4 = 1;  // (92)

	device::PORTA::PDR.B3 = 1;  // (94)
	device::PORTA::PDR.B2 = 1;  // (95)
	device::PORTA::PDR.B1 = 1;  // (96)
	device::PORTA::PDR.B0 = 1;  // (97)
	device::PORT6::PDR.B7 = 1;  // (98)
	device::PORT6::PDR.B6 = 1;  // (99)
	device::PORT6::PDR.B5 = 1;  // (100)
	device::PORTE::PDR.B7 = 1;  // (101)
	device::PORTE::PDR.B6 = 1;  // (102)

	device::PORT7::PDR.B0 = 1;  // (104)

	device::PORTE::PDR.B5 = 1;  // (106)
	device::PORTE::PDR.B4 = 1;  // (107)

	device::PORTE::PDR.B0 = 1;  // (111)
	device::PORT6::PDR.B4 = 1;  // (112)
	device::PORT6::PDR.B3 = 1;  // (113)
	device::PORT6::PDR.B2 = 1;  // (114)
	device::PORT6::PDR.B1 = 1;  // (115)

	device::PORT6::PDR.B0 = 1;  // (117)

	device::PORTD::PDR.B7 = 1;  // (119)
	device::PORTD::PDR.B6 = 1;  // (120)
	device::PORTD::PDR.B5 = 1;  // (121)
	device::PORTD::PDR.B4 = 1;  // (122)
	device::PORTD::PDR.B3 = 1;  // (123)
	device::PORTD::PDR.B2 = 1;  // (124)
	device::PORTD::PDR.B1 = 1;  // (125)
	device::PORTD::PDR.B0 = 1;  // (126)

	device::PORT9::PDR.B3 = 1;  // (127)
	device::PORT9::PDR.B2 = 1;  // (128)
	device::PORT9::PDR.B1 = 1;  // (129)

	device::PORT9::PDR.B0 = 1;  // (131)

	device::PORT4::PDR.B7 = 1;  // (133)
	device::PORT4::PDR.B6 = 1;  // (134)
	device::PORT4::PDR.B5 = 1;  // (135)
	device::PORT4::PDR.B4 = 1;  // (136)
	device::PORT4::PDR.B3 = 1;  // (137)
	device::PORT4::PDR.B2 = 1;  // (138)
	device::PORT4::PDR.B1 = 1;  // (139)

	device::PORT0::PDR.B7 = 1;  // (144)

	device::SYSTEM::PRCR = 0xA50B;	// クロック、低消費電力、関係書き込み許可

	device::SYSTEM::MOSCWTCR = 9;	// 1ms wait
	// メインクロック強制発振とドライブ能力設定
	device::SYSTEM::MOFCR = device::SYSTEM::MOFCR.MODRV2.b(0b10)
						  | device::SYSTEM::MOFCR.MOFXIN.b(1);
	device::SYSTEM::MOSCCR.MOSTP = 0;		// メインクロック発振器動作
	while(device::SYSTEM::OSCOVFSR.MOOVF() == 0) asm("nop");

	// Base Clock 12.5MHz
	// PLLDIV: 1/1, STC: 19 倍(237.5MHz)
	device::SYSTEM::PLLCR = device::SYSTEM::PLLCR.PLIDIV.b(0) |
							device::SYSTEM::PLLCR.STC.b(0b100101);
	device::SYSTEM::PLLCR2.PLLEN = 0;			// PLL 動作
	while(device::SYSTEM::OSCOVFSR.PLOVF() == 0) asm("nop");

	device::SYSTEM::SCKCR = device::SYSTEM::SCKCR.FCK.b(2)		// 1/2 (237.5/4= 59.375)
						  | device::SYSTEM::SCKCR.ICK.b(1)		// 1/2 (237.5/2=118.75)
						  | device::SYSTEM::SCKCR.BCK.b(2)		// 1/2 (237.5/4= 59.375)
						  | device::SYSTEM::SCKCR.PCKA.b(1)		// 1/2 (237.5/2=118.75)
						  | device::SYSTEM::SCKCR.PCKB.b(2)		// 1/4 (237.5/4= 59.375)
						  | device::SYSTEM::SCKCR.PCKC.b(2)		// 1/4 (237.5/4= 59.375)
						  | device::SYSTEM::SCKCR.PCKD.b(2);	// 1/4 (237.5/4= 59.375)
	device::SYSTEM::SCKCR2 = device::SYSTEM::SCKCR2.UCK.b(0b0100) | 1;  // USB Clock: 1/5 (237/5)
	device::SYSTEM::SCKCR3.CKSEL = 0b100;	///< PLL 選択

	LED::DIR = 1;

	{
		// タイマー設定(100Hz)
		uint8_t cmt_irq_level = 3;
		cmt_.start(100, cmt_irq_level);
	}

	{  // TPU0 設定
		uint8_t int_level = 4;
		if(!tpu0_.start(375000, int_level)) {
			utils::format("TPU0 not start ...\n");
		}
	}

	{  // DEBUG SCI 設定
		uint8_t int_level = 1;
		d_sci_.start(115200, int_level);
	}

	{  // MAIN SCI 設定
		uint8_t int_level = 1;
		m_sci_.start(115200, int_level);
		m_sci_.auto_crlf(false);
	}

	{  // D/A CH0, AMP enable
		dac_.start(DAC::output::CH0, true);
	}

	{  // LTC2348ILX-16 初期化
		LTC_PD::DIR = 1;
		LTC_PD::P = 0;  // パワーダウンしない!
		// 内臓リファレンスと内臓バッファ
		// VREFIN: 2.024V、VREFBUF: 4.096V、Analog range: -10.24V to +10.24V
		if(!eadc_.start(800000, EADC::span_type::M10_24P10_24)) {
			utils::format("LTC2348_16 not found...\n");
		}
	}

#if 0
	irq_count_ = 0;
	irq_state_ = 0;
#endif

	cap_pos_ = 0;
	cap_cnt_ = 0;
	cap_enable_ = false;

	// 初期設定
	dac_.out0(32768);  // トリガー電圧0V

	uint8_t cnt = 0;
	while(1) {
		cmt_.sync();

		switch(task_) {
		case TASK::STATE:
			if(m_sci_.recv_length() >= 1) {
				CMD cmd = static_cast<CMD>(m_sci_.getch());
				switch(cmd) {
				case CMD::START:
					cap_enable_ = true;
					task_ = TASK::LENGTH;
					break;
				case CMD::ASC_CNVTEST:
					cap_enable_ = true;
					send_task_ = SEND_TASK::ASCII_SINGLE;
					break;
				case CMD::ASC_CNVTESTS:
					cap_enable_ = true;
					send_task_ = SEND_TASK::ASCII_MULTI;
					break;
				case CMD::BIN_CNVTEST:
					cap_enable_ = true;
					send_task_ = SEND_TASK::BIN_SINGLE;
					break;
				case CMD::BIN_CNVTESTS:
					cap_enable_ = true;
					send_task_ = SEND_TASK::BIN_MULTI;
					break;
				case CMD::END:
					if(send_task_ == SEND_TASK::MULTI) {  // 波形取得を強制終了
						send_task_ = SEND_TASK::READY;
					}
					break;

				case CMD::TEST_TRG_P:
					trg_slope_ = true;
					req_cnt_ = 1024;
					trg_enable_ = true;
					trigger_ = TRIGGER::P();
					cap_enable_ = true;
					send_task_ = SEND_TASK::TRG;
					break;
				case CMD::TEST_TRG_N:
					trg_slope_ = false;
					req_cnt_ = 1024;
					trg_enable_ = true;
					trigger_ = TRIGGER::P();
					cap_enable_ = true;
					send_task_ = SEND_TASK::TRG;
					break;

				case CMD::MODE_SELECT:
					break;

				case CMD::MODE_SENSE:
					break;

				case CMD::VER:
					m_sci_.putch(0x21);  // VERデータID
					m_sci_.putch(20);  // 電圧レンジ(+-20V)
					{
						char tmp[4];
						auto v = main_version_;
						tmp[3] = (v % 10) + '0';
						v /= 10;
						tmp[2] = (v % 10) + '0';
						v /= 10;
						tmp[1] = (v % 10) + '0';
						v /= 10;
						tmp[0] = (v % 10) + '0';
						m_sci_.putch(tmp[3]);
						m_sci_.putch(tmp[2]);
						m_sci_.putch(tmp[1]);
						m_sci_.putch(tmp[0]);
					}
					break;

				default:
					break;
				}
			}
			break;

		case TASK::LENGTH:
			if(m_sci_.recv_length() >= (2 + 1)) {
				length_  = static_cast<uint8_t>(m_sci_.getch());
				length_ <<= 8;
				length_ |= static_cast<uint8_t>(m_sci_.getch());
				task_ = TASK::VOLT;
			}
			break;

		case TASK::VOLT:
			if(m_sci_.recv_length() >= (2 + 1)) {
				volt_  = static_cast<uint8_t>(m_sci_.getch());
				volt_ <<= 8;
				volt_ |= static_cast<uint8_t>(m_sci_.getch());
				// start command 追加仕様(5月14日、2018年)
				edge_ = static_cast<uint8_t>(m_sci_.getch());
				task_ = TASK::STATE;
				dac_.out0(volt_);  // トリガー電圧設定
///				if(volt_ < 32768) trg_slope_ = false;
///				else trg_slope_ = true;
				if(edge_ == 0) trg_slope_ = true;
				else trg_slope_ = false;
				if(length_ == 0) {
					cap_cnt_ = 1;
					trg_enable_ = false;
					cap_enable_ = true;
					send_task_ = SEND_TASK::SINGLE;
				} else {
					uint16_t n = length_;
					if(length_ > 1024) n = 1024;
					req_cnt_ = n;
					trg_enable_ = true;
					trigger_ = TRIGGER::P();
					cap_enable_ = true;
					send_task_ = SEND_TASK::MULTI;
				}
			}
			break;

		default:
			break;
		}

		switch(send_task_) {

		case SEND_TASK::SINGLE:
			copy_(cap_pos_, 1);
			send_wave_legacy_(0x01, 1, ch0_trg_);
			send_wave_legacy_(0x02, 1, ch1_trg_);
			send_task_ = SEND_TASK::READY;
			break;

		case SEND_TASK::MULTI:
			if(cap_cnt_ == 0 && !trg_enable_) ;
			else break;
			copy_(trg_pos_, length_);
			send_wave_legacy_(0x01, length_, ch0_trg_);
			send_wave_legacy_(0x02, length_, ch1_trg_);
			send_task_ = SEND_TASK::READY;
			break;

		case SEND_TASK::TRG:
			if(cap_cnt_ == 0 && !trg_enable_) ;
			else break;
			copy_(trg_pos_, 1024);
			send_wave_(0x01, 1024, ch0_trg_);
			send_wave_(0x02, 1024, ch1_trg_);
			send_task_ = SEND_TASK::READY;
			break;

		case SEND_TASK::BIN_SINGLE:
			copy_(cap_pos_, 1);
			send_wave_(0x01, 1, ch0_trg_);
			send_wave_(0x02, 1, ch1_trg_);
			send_task_ = SEND_TASK::READY;
			break;

		case SEND_TASK::BIN_MULTI:
			copy_(cap_pos_, 1024);
			send_wave_(0x01, 1024, ch0_trg_);
			send_wave_(0x02, 1024, ch1_trg_);
			send_task_ = SEND_TASK::READY;
			break;

		case SEND_TASK::ASCII_SINGLE:
			{
				copy_(cap_pos_, 1);
				char tmp[128];
				utils::sformat("%d,%d\r\n", tmp, sizeof(tmp)) % ch0_trg_[0] % ch1_trg_[0];
				m_sci_.puts(tmp);
			}
			send_task_ = SEND_TASK::READY;
			break;
		case SEND_TASK::ASCII_MULTI:
			{
				copy_(cap_pos_, 1024);
				for(uint16_t i = 0; i < 1024; ++i) {
					char tmp[128];
					utils::sformat("%d,%d,%d\r\n", tmp, sizeof(tmp))
						% i % ch0_trg_[i] % ch1_trg_[i];
					m_sci_.puts(tmp);
				}
			}
			send_task_ = SEND_TASK::READY;
			break;

		default:
			break;
		}
#if 1
		++cnt;
		if(cnt >= 50) {
			cnt = 0;
		}
		if(cnt >= 35) {
			LED::P = 1;
		} else {
			LED::P = 0;
		}
#endif
	}
}
void ELS139_semant_(ptr self__, ptr symtab__)
{
   SATHER_STR_(20,53,ls2610_,"(ELSIF_STMTOB_S): Test in \"elsif\" has no return type");
   SATHER_STR_(20,69,ls2611_,"(ELSIF_STMTOB_S): Test in \"elsif\" statement should return BOOL value");
   ptr gl3428_;
   static int gl3429_;
   static union dtype_ gl3430_;
   ptr gl3431_;
   static int gl3432_;
   static union dtype_ gl3433_;
   ptr gl329_;
   ptr gl3434_;
   static int gl3435_;
   static union dtype_ gl3436_;
   ptr gl3437_;
   static int gl3438_;
   static union dtype_ gl3439_;
   ptr gl3440_;
   static int gl3441_;
   static union dtype_ gl3442_;
   ptr gl3443_;
   static int gl3444_;
   static union dtype_ gl3445_;
   ptr gl3446_;
   static int gl3447_;
   static union dtype_ gl3448_;
   char gl330_;
   ptr gl3449_;
   static int gl3450_;
   static union dtype_ gl3451_;

   gl3428_ = PATT_(self__,12);
   cache_dispatch_(gl3428_,588,gl3429_,INTVAL_(gl3430_));
   VFN_(gl3430_)(gl3428_,symtab__);
   gl3431_ = PATT_(self__,12);
   cache_dispatch_(gl3431_,1577,gl3432_,INTVAL_(gl3433_));
   gl329_ = PATT_(gl3431_,INTVAL_(gl3433_));
   if ((gl329_ == 0)) {
      ERR96_format_error_msg_(0,IATT_(self__,4),STR20_s_(STR20_create_(0),(ptr)(&ls2610_)));
      gl3434_ = PATT_(self__,12);
      cache_dispatch_(gl3434_,1577,gl3435_,INTVAL_(gl3436_));
      PATT_(gl3434_,INTVAL_(gl3436_)) = (ptr)copy_(GLO68_bool_typeob_s_,1);
      gl3440_ = PATT_(self__,12);
      cache_dispatch_(gl3440_,1577,gl3441_,INTVAL_(gl3442_));
      gl3437_ = PATT_(gl3440_,INTVAL_(gl3442_));
      cache_dispatch_(gl3437_,298,gl3438_,INTVAL_(gl3439_));
      IATT_(gl3437_,INTVAL_(gl3439_)) = (int)IATT_(self__,4);
   }
   else {
   }
   gl3446_ = PATT_(self__,12);
   cache_dispatch_(gl3446_,1577,gl3447_,INTVAL_(gl3448_));
   gl3443_ = PATT_(gl3446_,INTVAL_(gl3448_));
   cache_dispatch_(gl3443_,1768,gl3444_,INTVAL_(gl3445_));
   gl330_ = CFN_(gl3445_)(gl3443_);
   if ((! gl330_)) {
      ERR96_format_error_msg_(0,IATT_(self__,4),STR20_s_(STR20_create_(0),(ptr)(&ls2611_)));
      gl3449_ = PATT_(self__,12);
      cache_dispatch_(gl3449_,1577,gl3450_,INTVAL_(gl3451_));
      PATT_(gl3449_,INTVAL_(gl3451_)) = (ptr)copy_(GLO68_bool_typeob_s_,1);
   }
   else {
   }
   SYM186_enter_new_scope_(symtab__);
   LST123_semant_(PATT_(self__,16),symtab__);
   SYM186_leave_new_scope_(symtab__);

   ret0__:
   return;
}
示例#14
0
void
Restore::operator()()
{
    LOG_INFO("Starting the Restore");

    bpt::ptree total_pt;
    bpt::json_parser::read_json(configuration_file_.string(),
                                total_pt);

    init_(total_pt);

    const bpt::ptree& target_pt = total_pt.get_child("target_configuration");

    be::BackendConnectionManagerPtr
        target_cm(be::BackendConnectionManager::create(target_pt,
                                                       RegisterComponent::F));

    const std::string target_nspace(target_pt.get<std::string>("namespace"));

    be::BackendInterfacePtr
        target_bi(target_cm->newBackendInterface(backend::Namespace(target_nspace)));

    const boost::optional<bpt::ptree&>
        maybe_source_pt(total_pt.get_child_optional("source_configuration"));

    vd::VolumeConfig vol_config;

    if (maybe_source_pt)
    {
        const std::string source_ns((*maybe_source_pt).get<std::string>("namespace"));

        be::BackendConnectionManagerPtr
            source_cm(be::BackendConnectionManager::create(*maybe_source_pt,
                                                           RegisterComponent::F));

        be::BackendInterfacePtr source_bi(source_cm->newBackendInterface(backend::Namespace(source_ns)));
        copy_(source_bi->clone(), target_bi->clone());

        LOG_INFO("Retrieving volume config from source namespace " <<
                 source_bi->getNS());
        source_bi->fillObject(vol_config, InsistOnLatestVersion::T);
        vol_config.changeNamespace(backend::Namespace(target_nspace));
    }
    else
    {
        LOG_INFO("Retrieving volume config from target namespace " <<
                 target_bi->getNS());
        target_bi->fillObject(vol_config, InsistOnLatestVersion::T);
    }

    const boost::optional<std::string>
        maybe_new_name(target_pt.get_optional<std::string>("volume_name"));

    if (maybe_new_name)
    {
        LOG_INFO(target_nspace << ": renaming " << vol_config.id_ << " -> " <<
                 *maybe_new_name);
        const_cast<vd::VolumeId&>(vol_config.id_) = vd::VolumeId(*maybe_new_name);
    }

    const boost::optional<vd::VolumeConfig::WanBackupVolumeRole>
        maybe_new_role(target_pt.get_optional<vd::VolumeConfig::WanBackupVolumeRole>("volume_role"));

    if (maybe_new_role)
    {
        promote_(*maybe_new_role, target_bi->clone(), vol_config);
    }

    target_bi->writeObject(vol_config,
                           vd::VolumeConfig::config_backend_name,
                           OverwriteObject::T);
}