示例#1
0
void StorageJoin::truncate(const ASTPtr &)
{
    Poco::File(path).remove(true);
    Poco::File(path).createDirectories();
    Poco::File(path + "tmp/").createDirectories();

    increment = 0;
    join = std::make_shared<Join>(key_names, key_names, NameSet(), false /* use_nulls */, SizeLimits(), kind, strictness);
    join->setSampleBlock(getSampleBlock().sortColumns());
}
示例#2
0
StorageJoin::StorageJoin(
    const String & path_,
    const String & name_,
    const Names & key_names_,
    ASTTableJoin::Kind kind_, ASTTableJoin::Strictness strictness_,
    const ColumnsDescription & columns_)
    : StorageSetOrJoinBase{path_, name_, columns_},
    key_names(key_names_), kind(kind_), strictness(strictness_)
{
    for (const auto & key : key_names)
        if (!getColumns().hasPhysical(key))
            throw Exception{"Key column (" + key + ") does not exist in table declaration.", ErrorCodes::NO_SUCH_COLUMN_IN_TABLE};

    /// NOTE StorageJoin doesn't use join_use_nulls setting.

    join = std::make_shared<Join>(key_names, key_names, NameSet(), false /* use_nulls */, SizeLimits(), kind, strictness);
    join->setSampleBlock(getSampleBlock().sortColumns());
    restore();
}
示例#3
0
int main(void)
{
    u08 i,j,g,sel,rm;

    //Key 
    PORTD=0x00;
    DDRD=0xff;

    sbi(DDRD,5);
    cbi(DDRD,2);
    cbi(DDRD,3);
    cbi(DDRD,4);
    sbi(PORTD,6);
    cbi(PORTD,5);


    cbi(PORTA,RST);
    LCDINI();

    Page0:
    LCDGOTOXY(1,0);

    /// draws smart home picture
    for(i=0;i<=62;i++)
        for(j=0;j<=7;j++)
            spi_write(Welup[i][j]);

    for(i=0;i<10;i++)
        _delay_ms(200);

     cbi(PORTA,RST);

     Mainmenu:
    sbi(PORTA,RST);
    LCDBRD();/// draws border
    LCDCLR();// clear lcd


    //displays date and time
    LCDSTR(date,1,1,0);
    LCDSTR(time,8,2,0);
    LCDMEN("H O M E",4,4);

    //waiting for key
    Page:
    if(getKey()!=KEY_OK) goto Page;

//MENU Page 0 // menu list 
    Menulist:
    pos=0;             //pos=highlighted position //all  room names and total no of rooms
    LCDCLR();
    for(i=0;i<T_1;i++)
       ri[i]=i;   
    rmdisp(T_1,0,0);
   
    while(1)
    {
        g=getKey();
        if(g==KEY_DOWN || g==KEY_UP)
            rmdisp(T_1,g,0);
        else if (g==KEY_BACK)
        goto Mainmenu;
        else if(g==KEY_OK) 
        break;
    }   


sel=ri[pos];

   if ( sel == 3)// set time - time syncronize with central server(cordinator) date time()
   {
       TimeSet();
       goto Menulist;
   }
//   PORTB=sel;
/////////////////////////////////////////////////////////////////////////////////////////////
// 
//ROOMS Disp page 1 pressing of ok
   Roomlist:
   pos=0;
//Page3:
   LCDCLR();

   for(i=0;i<RNO;i++)
    ri[i]=i;   
rmdisp(RNO,0,1);
while(1)
{
    g=getKey();
    if(g==KEY_UP || g==KEY_DOWN)
      rmdisp(RNO,g,1);
  else if(g==KEY_BACK)
      goto Menulist;
  else if(g==KEY_OK) 
   break;
//   delayms(7000);
}
rm=ri[pos]+1;

// selection based values ie room choice->temp ,pressure,control etc
//SENSOR Status Page 2 

pos=0;
if(sel==0) rmdisp(8,0,2);
while(sel==0)
{
 g=getKey();
 if(g==KEY_DOWN || g==KEY_UP)
   rmdisp(10,g,2);
else if (g==KEY_BACK)
    goto Roomlist;
else if(g==KEY_OK) goto Roomlist;
 //      delayms(7000);
}



pos=0;   //////////////////////////////////////control page switch display
if(sel==1)
{

  j=20;
  for(i=0;i<j;i++)
     ri[i]=i;
 swi(j,0,0);
 while(1)
 {
     g=getKey();
     if(g==KEY_UP || g==KEY_DOWN)
       swi(j,g,0);
   else if(g==KEY_STAR) 
   { 
       switc[ri[pos]][6] = switc[ri[pos]][6] ^ 0xff; 
       swi(j,12,0);
   }
   else if(g==KEY_OK)  goto Roomlist;
}
goto Page0;
}
else if(sel==4)
{
   pos=0;
   NameSet(1,rm);
   goto Menulist;
}
else if(sel==5)
{
  j=0;
  for(i=0;i<20;i++)
  {
     rd[j++]=i;
 }

 for(i=0;i<=j;i++)
     ri[i]=i;
 rmdisp(j+1,0,4);
 while(1)
 {
     g=getKey();
     if(g==KEY_DOWN || g==KEY_UP)
       rmdisp(j+1,g,4);
   else if(g==KEY_OK) break;
}

pos=0;
NameSet(0,ri[pos]);
goto Menulist;

}
else if(sel==2)
{
  SchSwitch:

  for(i=0;i<10;i++)
     ri[i]=i;
 swi(10,0,1);
 while(1)
 {
     g=getKey();
     if(g==KEY_DOWN || g==KEY_UP)
       swi(10,g,1);
   else if (g==KEY_STAR)
   {
       sch[ri[pos]][3]  =sch[ri[pos]][3] ^ 0x01;
       swi(10,19,1);
   }
   else if (g==KEY_BACK)
    goto Roomlist;
else if(g==KEY_OK) break;
}
j=ri[pos];
SchDisp:
LCDCLR();
schd(j,0);
pos=0;
while(1)
{
   g=getKey();
   if(g<=KEY_9 || g==KEY_STAR) 
      SchTimeSet(g,j);
  else if(g==KEY_DOWN && pos <16) pos =(pos +1);
  else if(g==KEY_UP && pos>0)   pos = (pos-1); 
  schd(j,0);
  if (g==KEY_BACK)
      goto SchSwitch;
  else
   if(g==KEY_OK)
   {
     g=SchTimeChk(j);
     if(g==1) goto SchDisp;
     else    goto Mainmenu;
 }
}

}

cbi(PORTA,4);

while(1);
return 0;
}
示例#4
0
NamesAndTypesList NamesAndTypesList::filter(const Names & names) const
{
    return filter(NameSet(names.begin(), names.end()));
}
示例#5
0
void CProject::CalculateAmpVarPeriod(int freqpnt, int *freqdat, 
				     int what, CalcMode mode)
{
  UpdatePEData();
  // check if weights should be used
  if (!Period.GetUseWeight())
    {
      if (Timestring.GetSelectedPoints()!=Timestring.GetWeightSum())
	{
	  if (Confirm(DIALOG_PERIOD_USE_WEIGHTS)==1)
	    { Period.SetUseWeight(1); }
	}
    }

  // Set Frequencies for Amplitude Variations
  int i;
  for (i=0;i<freqpnt;i++)
    {
      Period[freqdat[i]].SetAmpVar(mode);
    }
  // what names should be used ?
  Period.SetUseID(what);

  // PROTOCOL

  // Write Calculation-header
  char tempprot[AMPVARMSGBUFFER];
  for (i=0;i<AMPVARMSGBUFFER;i++) { tempprot[i]=0; }
  char txt[1024];
  ostrstream pro(tempprot,AMPVARMSGBUFFER);
  pro<<PROTOCOL_AMPVAR_CALCULATE_HEADER<<endl;
  //WriteFrequenciesTabulated(pro,1);
  //sprintf(txt,PROTOCOL_ZEROPOINT,Period.GetZeropoint());
  //pro<<txt<<endl;
  if (Period.GetUseWeight())
    { pro<<PROTOCOL_PERIOD_USE_WEIGHTS<<endl; }
  pro<<PROTOCOL_AMPVAR_NAMES_SELECTED<<NameSet(what)<<endl;
  pro<<PROTOCOL_PERIOD_CALCULATION_STARTED<<Date()<<endl;
  pro<<char(0)<<flush;  
  Waiting(1,1);
  // Calculate
  switch (Period.Calc(Timestring))
    {
    case 0:
      {
	// Write Calculation-footer
	ostream &tmp=Write();
	tmp<<pro.str();
	tmp<<PROTOCOL_PERIOD_OUTPUT<<endl;
	// now write the protocol
	char txt1[AMPVARMSGBUFFER];
	for (i=0;i<AMPVARMSGBUFFER;i++) { txt1[i]=0; }
	ostrstream pro1(txt1,AMPVARMSGBUFFER);
	
	// general data..
	CTimeString &Timestring=GetTimeString();
	CPeriod const &Period=GetPeriod();
	
	int freqs=Period.GetFrequencies();
	
	// now fill in the data...
	for (int fre=0;fre<freqs;fre++)
	  {
	    int fr=fre;
	    if (Period[fr].GetActive())
	      {
		switch (Period[fr].GetAmpVariation())
		  {
		  case NoVar:
		    {
		      sprintf(txt,PROTOCOL_AMPVAR_NOVAR,
			      GetNumber(fr).chars(),
			      GetFrequency(fr).chars(),
			      Period[fr].GetAmplitude(-1),
			      Period[fr].GetPhase(-1)
			      );
		      // write out
		      pro1<<txt<<endl;
		      tmp<<txt<<endl;
		      break;
		    }
		  case AmpVar:
		    {
		      // first write out the header
		      sprintf(txt,PROTOCOL_AMPVAR_AMPVAR_HEAD,
			      GetNumber(fr).chars(),
			      GetFrequency(fr).chars(),
			      Period[fr].GetPhase(-1)
			      );
		      // write out
		      pro1<<txt<<endl;
		      tmp<<txt<<endl;
		      // now write out the relevant data
		      for (int na=0;na<Timestring.NumberOfNames(what);na++)
			{
			  int id=
			    Timestring.GetIndexName(what,na).GetID();
			  int points=
			    Timestring.GetIndexName(what,na).GetPoints();
			  myString name=
			    Timestring.GetIndexName(what,na).GetName();
			  if (points!=0)
			    {
			      sprintf(txt,PROTOCOL_AMPVAR_AMPVAR,
				      name.chars(),
				      Period[fr].GetAmplitude(id)
				      );
			      // write out
			      pro1<<txt<<endl;
			      tmp<<txt<<endl;
			    }
			}
		      break;  
		    }
		  case PhaseVar:
		    {
		      // first write out the header
		      sprintf(txt,PROTOCOL_AMPVAR_PHASEVAR_HEAD,
			      GetNumber(fr).chars(),
			      GetFrequency(fr).chars(),
			      Period[fr].GetAmplitude(-1)
			      );
		      // write out
		      pro1<<txt<<endl;
		      tmp<<txt<<endl;
		      // now write out the relevant data
		      for (int na=0;na<Timestring.NumberOfNames(what);na++)
			{
			  int id=
			    Timestring.GetIndexName(what,na).GetID();
			  int points=
			    Timestring.GetIndexName(what,na).GetPoints();
			  myString name=
			    Timestring.GetIndexName(what,na).GetName();
			  if (points!=0)
			    {
			      sprintf(txt,PROTOCOL_AMPVAR_PHASEVAR,
				      name.chars(),
				      Period[fr].GetPhase(id)
				      );
			      // write out
			      pro1<<txt<<endl;
			      tmp<<txt<<endl;
			    }
			}
		      break;  
		    }
		  case AllVar:
		    {
		      // first write out the header
		      sprintf(txt,PROTOCOL_AMPVAR_ALLVAR_HEAD,
			      GetNumber(fr).chars(),
			      GetFrequency(fr).chars()
			      );
		      // write out
		      pro1<<txt<<endl;
		      tmp<<txt<<endl;
		      // now write out the relevant data
		      for (int na=0;na<Timestring.NumberOfNames(what);na++)
			{
			  int id=
			    Timestring.GetIndexName(what,na).GetID();
			  int points=
			    Timestring.GetIndexName(what,na).GetPoints();
			  myString name=
			    Timestring.GetIndexName(what,na).GetName();
			  if (points!=0)
			    {
			      sprintf(txt,PROTOCOL_AMPVAR_ALLVAR,
				      name.chars(),
				      Period[fr].GetAmplitude(id),
				      Period[fr].GetPhase(id)
				      );
			      // write out
			      pro1<<txt<<endl;
			      tmp<<txt<<endl;
			    }
			}
		      break;  
		    }
		  }
	      }
	  }
	
	// now write the rest..
	sprintf(txt,PROTOCOL_PERIOD_RESULT,
		Period.GetZeropoint(),
		Period.GetResiduals(),
		Period.GetIterations());
	pro1<<txt<<flush;
	tmp<<txt<<flush;
	// Have we reached Maximum Number Iterations?
	if (Period.GetIterations()>=Period.MaxIterations())
	  {
	    InformUser(DIALOG_PERIOD_MAXIMUM_ITERATIONS);	  
	  }
	// now display the data...
	DisplayAmpVarData(pro1.str());
	break;
      }
    case 1:// Matrix cannot be inverted
      {
	InformUser(DIALOG_PERIOD_MATRIX_INVERSION);
	break;
      }
    case 2:// cancel pressed, may not be a stable solution
      {
	InformUser(DIALOG_PERIOD_CALCULATION_INTERRUPTED);
	break;
      }
    }
  
  Waiting(0);
  // Cleans Frequencies of Amplitude Variations
  for (i=0;i<freqpnt;i++)
    {
      Period[freqdat[i]].SetAmpVar(NoVar);
    }
  UpdatePEDisplays();
}