Exemplo n.º 1
0
int SetPrintPara2()
{
   BEGINOK1;
   SetP(PG.PageBlock[CurrentBlock].Xscale, PrintCutWin[wXSCALEWIN]);
   SetP(PG.PageBlock[CurrentBlock].Yscale, PrintCutWin[wYSCALEWIN]);
   return 0;
}
Exemplo n.º 2
0
int SetPrintPara1()
{
   BEGINOK1;
   SetP(PG.PageBlock[CurrentBlock].Xoffset,PrintCutWin[wXPICWIN]);
   SetP(PG.PageBlock[CurrentBlock].Yoffset,PrintCutWin[wYPICWIN]);
   return 0;
}
Exemplo n.º 3
0
/**
 * Sets control values for closed loop control.
 *
 * @param p Proportional constant.
 * @param i Integration constant.
 * @param d Differential constant.
 * @param f Feedforward constant.
 */
void CANTalon::SetPID(double p, double i, double d, double f)
{
	SetP(p);
	SetI(i);
	SetD(d);
	SetF(f);
}
Exemplo n.º 4
0
SRXSpeed::SRXSpeed(int id, double Pvalue, double Ivalue, double Dvalue, int a):CANTalon(id)
{
	SetControlMode(CANTalon::kSpeed);
	SetFeedbackDevice(CANTalon::QuadEncoder);
	SetP(Pvalue);
	SetI(Ivalue);
	SetD(Dvalue);
	EnableControl();
	maxTicks=a;
}
Exemplo n.º 5
0
void Solve()
{
  answer = false;
  p[7][0] = dots[7][0];
  p[7][1] = dots[7][1];
  p[7][2] = dots[7][2];
  //No recursion, i wanna copy-paste
  for(pIdx[0] = 0; pIdx[0] < 6; pIdx[0]++)
  {
    SetP(0);
    for(pIdx[1] = 0; pIdx[1] < 6; pIdx[1]++)
    {
      SetP(1);
      for(pIdx[2] = 0; pIdx[2] < 6; pIdx[2]++)
      {
        SetP(2);
        for(pIdx[3] = 0; pIdx[3] < 6; pIdx[3]++)
        {
          SetP(3);
          for(pIdx[4] = 0; pIdx[4] < 6; pIdx[4]++)
          {
            SetP(4);
            for(pIdx[5] = 0; pIdx[5] < 6; pIdx[5]++)
            {
              SetP(5);
              for(pIdx[6] = 0; pIdx[6] < 6; pIdx[6]++)
              {
                SetP(6);
                /*for(pIdx[7] = 0; pIdx[7] < 6; pIdx[7]++)
                {*/
                  //SetP(7);
                  /*if((p[0][0] == 0 && p[0][1] == 0 && p[0][2] == 0)
                   && (p[1][0] == 0 && p[1][1] == 0 && p[1][2] == 1)
                   && (p[2][0] == 0 && p[2][1] == 1 && p[2][2] == 0)
                   && (p[3][0] == 1 && p[3][1] == 0 && p[3][2] == 0)
                   && (p[4][0] == 0 && p[4][1] == 1 && p[4][2] == 1)
                   && (p[5][0] == 1 && p[5][1] == 0 && p[5][2] == 1)
                   && (p[6][0] == 1 && p[6][1] == 1 && p[6][2] == 0)
                   && (p[7][0] == 1 && p[7][1] == 1 && p[7][2] == 1))
                  {
                    printf("Surprise Neo");
                  }*/
                  if(check())
                  {
                    answer = true;
                    return;
                  }
                //}
              }
            }
          }
        }
      }
    }
  }
}
Exemplo n.º 6
0
void Rect::Mirroring(Tan** tans) {   
    Vector vec[4];
    
    vec[0].Set(start_vectors[0].GetX(),start_vectors[2].GetY());
    vec[1].Set(start_vectors[1].GetX(),start_vectors[3].GetY());
    vec[2].Set(start_vectors[2].GetX(),start_vectors[0].GetY());
    vec[3].Set(start_vectors[3].GetX(),start_vectors[1].GetY());
    
    wxPoint temp_point;
    Vector temp_vectors[4];
    
    for(int j=0;j<GetSize();j++){
        temp_vectors[j] = matrix*vec[j];
        start_vectors[j] = vec[j];
        temp_point.x = temp_vectors[j].GetX();
        temp_point.y = temp_vectors[j].GetY();
        SetP(j+1,temp_point);
    }   
    
    if(Conflicts(this,tans)) 
    {
        vec[0].Set(start_vectors[0].GetX(),start_vectors[2].GetY());
        vec[1].Set(start_vectors[1].GetX(),start_vectors[3].GetY());
        vec[2].Set(start_vectors[2].GetX(),start_vectors[0].GetY());
        vec[3].Set(start_vectors[3].GetX(),start_vectors[1].GetY());
        
        wxPoint temp_point;
        Vector temp_vectors[4];
        
        for(int j=0;j<GetSize();j++){
            temp_vectors[j] = matrix*vec[j];
            start_vectors[j] = vec[j];
            temp_point.x = temp_vectors[j].GetX();
            temp_point.y = temp_vectors[j].GetY();
            SetP(j+1,temp_point);
        }   
    }

}
Exemplo n.º 7
0
int SetPrintPara()
{
   char p[30];
   int i,j;
   static int oldNum=0;

   BEGINOK1;
   //WaitMessageEmpty();
   for (j=0;j<4;j++)
   {
     if (MessageGo(PrintCutWin[wROTATE0+j],GETSTATUS,0l,0l))
       {
        i=j+wROTATE0;
        MessageGo(PrintCutWin[i],SETSTATUS,0l,0l);
        break;
       }
   }

   SetP(PG.PageBlock[CurrentBlock].Xoffset,PrintCutWin[wXPICWIN]);
   SetP(PG.PageBlock[CurrentBlock].Yoffset,PrintCutWin[wYPICWIN]);
   SetP(PG.PageBlock[CurrentBlock].Xscale, PrintCutWin[wXSCALEWIN]);
   SetP(PG.PageBlock[CurrentBlock].Yscale, PrintCutWin[wYSCALEWIN]);
   SetPI(PG.PageBlock[CurrentBlock].PageOffset,PrintCutWin[wPAGEOFFSETWIN]);
   SetPI(PG.PageInc,PrintCutWin[wPAGENUMWIN]);

   MessageGo(PrintCutWin[wROTATE0+PG.PageBlock[CurrentBlock].Rotate%4],SETSTATUS,1l,0l);

  if (oldNum!=PG.Blocks)
  {
   sprintf(p,"%2d",PG.Blocks);
   GetXY(2,&i,&j);
   DispXY(i-10,j,p,COLORPN);
   oldNum=PG.Blocks;
  }
  return 0;
}
Exemplo n.º 8
0
RELATION CloneRelation(RELATION id, RELATION cloneId)
{
    register struct relationDef *rd;

    if ((rd = FindRelation(id))) {
	if (AddRelation(cloneId) || FindRelation(cloneId)) {
	    register struct relation *r;

	    for (r = rd->rd_relationsTable; r; r = r->r_next) {
		SetP(r->r_leftKey, cloneId, r->r_rightKey, r->r_parameter);
	    }

	    return cloneId;
	}
    }

    return 0;
}
Exemplo n.º 9
0
SRXPosition::SRXPosition(int id, double p, double i, double d, bool invert):CANTalon(id) {
	SetControlMode(CANTalon::kPosition);
	SetP(p);
	SetI(i);
	SetD(d);
	SetFeedbackDevice(CANTalon::QuadEncoder);
	invertMotor=invert;
	SetInverted(invert);
	if (invert)
	{
		ConfigFwdLimitSwitchNormallyOpen(false);
	}
	else
	{
		ConfigRevLimitSwitchNormallyOpen(false);
	}
	SetPosition(0);
	target=0;
	EnableControl();
}
Exemplo n.º 10
0
void RgbEffects::Drawcircle(int xc,int yc,double radius,wxImage::HSVValue hsv)
{
    /*
    double 	wxDegToRad (double deg)
    Convert degrees to radians.

    double 	wxRadToDeg (double rad)
    Convert radians to degrees.

    Inside of #include <math.h> is this code, M_PI is wxwidgets definition of Pi

    #ifndef M_PI
    #define M_PI 3.1415926535897932384626433832795
    #endif

    t = (i+mod1440)*M_PI/180;
    x = (R-r) * cos (t) + d*cos (((R-r)/r)*t) + xc;
    y = (R-r) * sin (t) + d*sin (((R-r)/r)*t) + yc;

    if(colorcnt>0) d_mod = (int) BufferWi/colorcnt;
    else d_mod=1;

    x2= pow ((double)(x-xc),2);
    y2= pow ((double)(y-yc),2);
    hyp = (sqrt(x2 + y2)/BufferWi) * 100.0;
    */
    double degrees,radian;
    int x,y;
    for (degrees=0.0; degrees<360.0; degrees+=1.0)
    {
        radian = 	degrees * (M_PI/180.0);
        x = radius * cos(radian) + xc;
        y = radius * sin(radian) + yc;
        SetP(x,y,hsv); // Turn pixel
    }

}
Exemplo n.º 11
0
void RgbEffects::RenderRipple(int Object_To_Draw, int Movement)
{

    int x,y,i,i7,ColorIdx;
    int xc,yc;

#if 0
    if(step<1) step=1;
    if(Use_All_Colors) srand (time(NULL)); // for Use_All_Colors effect, make lights be random
    else srand(1); // else always have the same random numbers for each frame (state)
#endif

    wxImage::HSVValue hsv; //   we will define an hsv color model. The RGB colot model would have been "wxColour color;"
    srand (time(NULL));
    size_t colorcnt=GetColorCount();

    i=0;
    double position = GetEffectTimeIntervalPosition(); // how far are we into the row> value is 0.0 to 1.0
    float rx;
    xc = BufferWi/2;
    yc=BufferHt/2;
    int on_off=0;

    int slices=200;
    int istate=state/slices; // istate will be a counter every slices units of state. each istate is a square wave
    int imod=(state/(slices/10))%10; // divide this square
    int icolor=istate%colorcnt;
    wxString TimeNow =wxNow();
    rx=(state%slices)/(slices*1.0);

    int x1 = xc - (xc*rx);
    int x2 = xc + (xc*rx);
    int y1 = yc - (yc*rx);
    int y2 = yc + (yc*rx);
    enum {Square, Circle, Triangle} shape = Circle;
    double radius;
    //  debug(10, "%s:%6d istate=%4d imod=%4d icolor=%1d", (const char*)TimeNow,state,istate,imod,icolor);
    ColorIdx=rand()% colorcnt; // Select random numbers from 0 up to number of colors the user has checked. 0-5 if 6 boxes checked
    palette.GetHSV(ColorIdx, hsv); // Now go and get the hsv value for this ColorIdx
    int explode;
    switch (Object_To_Draw)
    {

    case RENDER_RIPPLE_SQUARE:
        explode=1;
        if(Movement==MOVEMENT_EXPLODE)
        {
            // This is the object expanding out, or explode looikng
            int x1 = xc - (xc*rx);
            int x2 = xc + (xc*rx);
            int y1 = yc - (yc*rx);
            int y2 = yc + (yc*rx);
            for(y=y1; y<=y2; y++)
            {
                SetP(x1,y,hsv); // Turn pixel
                SetP(x2,y,hsv); // Turn pixel
            }
            for(x=x1; x<=x2; x++)
            {
                SetP(x,y1,hsv); // Turn pixel
                SetP(x,y2,hsv); // Turn pixel
            }

            hsv.value = (hsv.value /3)*2;
            for(y=y1; y<=y2; y++)
            {
                SetP(x1+1,y,hsv); // Turn pixel
                SetP(x2-1,y,hsv); // Turn pixel
            }
            for(x=x1; x<=x2; x++)
            {
                SetP(x,y1+1,hsv); // Turn pixel
                SetP(x,y2-1,hsv); // Turn pixel
            }

            hsv.value = hsv.value /3;
            for(y=y1; y<=y2; y++)
            {
                SetP(x1+2,y,hsv); // Turn pixel
                SetP(x2-2,y,hsv); // Turn pixel
            }
            for(x=x1; x<=x2; x++)
            {
                SetP(x,y1+2,hsv); // Turn pixel
                SetP(x,y2-2,hsv); // Turn pixel
            }

        }
        else if(Movement==MOVEMENT_IMPLODE)
        {
            int x1 = (xc*rx);
            int x2 = BufferWi - (xc*rx);
            int y1 =  (yc*rx);
            int y2 = BufferHt - (yc*rx);
            for(y=y2; y>=y1; y--)
            {
                SetP(x1,y,hsv); // Turn pixel
                SetP(x2,y,hsv); // Turn pixel
            }
            for(x=x2; x>=x1; x--)
            {
                SetP(x,y1,hsv); // Turn pixel
                SetP(x,y2,hsv); // Turn pixel
            }
        }
        break;
    case RENDER_RIPPLE_CIRCLE:
        if(Movement==MOVEMENT_IMPLODE)
            radius = xc-(xc*rx);
        else
            radius = (xc*rx);


        Drawcircle( xc, yc, radius, hsv);
        radius=radius/2;
        Drawcircle( xc, yc, radius, hsv);
        radius=radius/2;
        Drawcircle( xc, yc, radius, hsv);
        radius=radius/2;
        Drawcircle( xc, yc, radius, hsv);
        break;
    case RENDER_RIPPLE_TRIANGLE:
        break;
    }
}
Exemplo n.º 12
0
int LoadRelations(char *file, U16 disk_id)
{
    RELATION rd;
    PARAMETER parameter;
    char buffer[256];
    char left[256];
    char right[256];
    U8 goOn;
    FILE *fh = NULL;
    U32 dummy;

    buffer[0] = '\0';
    left[0] = '\0';
    right[0] = '\0';

    if (EncodeKey) {
	if ((fh = dskOpen(file, "rb"))) {
	    dskGetLine(buffer, sizeof(buffer), fh);

	    if (strcmp(buffer, REL_FILE_MARK) == 0) {
		dskGetLine(buffer, sizeof(buffer), fh);

		while (!feof(fh) && strcmp(buffer, REL_TABLE_MARK) == 0) {
		    fscanf(fh, "%" SCNu32 "\r\n", &rd);

		    goOn = 0;
		    if (FindRelation(rd))
			goOn = 1;
		    else {
			if (AddRelation(rd))
			    goOn = 1;
		    }

		    if (goOn) {
			while (dskGetLine(left, sizeof(left), fh)) {
			    if (strcmp(left, REL_TABLE_MARK) == 0) {
				strcpy(buffer, left);
				break;
			    }

			    if (sscanf(left, "%" SCNu32, &dummy) != 1)
				break;

			    dskGetLine(right, sizeof(right), fh);

			    if (sscanf(right, "%" SCNu32, &dummy) != 1)
				break;

			    if (fscanf(fh, "%" SCNu32 "\r\n", &parameter) != 1)
				break;

			    if (!SetP
				(EncodeKey(left), rd, EncodeKey(right),
				 parameter)) {
				dskClose(fh);
				return 0;
			    }
			}
		    } else {
			dskClose(fh);
			return 0;
		    }
		}

		dskClose(fh);
		return 1;
	    }

	    dskClose(fh);
	}
    }

    return 0;
}
Exemplo n.º 13
0
void SRXSpeed::ChangePID(float P, float I, float D)
{
	SetP(P);
	SetI(I);
	SetD(D);
}