示例#1
0
Pot::Pot(int _x, int _y,Component * _diagram):ConnectedComponent(_x,_y,_diagram)
{ 
  offOn = false;
  analogInput = new Pin (this);
  gnd = new Pin(this);
  power = new Pin(this);
  power->xOffset = 20;
  power->yOffset = 151;
  analogInput->xOffset = 43;
  analogInput->yOffset = 151;
  gnd->xOffset = 68;
  gnd->yOffset = 151;
  x = _x;
  y = _y;
  gnd->x = x + gnd->xOffset;
  gnd->y = y + gnd->yOffset;    
  power->x = x + power->xOffset;
  power->y = y + power->yOffset; 
  analogInput->x = x + analogInput->xOffset;
  analogInput->y = y + analogInput->yOffset;
  power->SetName ("POT +");
  gnd->SetName ("POT -");
  analogInput->SetName ("POT A");  
  SaveType ("POT");       
}
示例#2
0
RotaryDip::RotaryDip(int _x, int _y, Component * _diagram): ConnectedComponent(_x,_y,_diagram)
{ 
  char names[][MAX_ROTARYDIP_PINS] = {"pin01", "pin02", "pin03", "pin04", "pin05", "pin06"};
  int xOff[] = {2,2,2,120,120,120};
  int yOff[] = {35,65,95,95,65,35};
  pinSelected = false;
  rotateDial = false;
  whichDip = 0;
  x = _x;
  y = _y;
  clearTheText = false; 
  
  for (int i=0; i<MAX_ROTARYDIP_PINS; i++)
  {
    pin[i] = new Pin(this);
  	pin[i]->SetName ( names[i] );
  	pin[i]->xOffset = xOff[i];
  	pin[i]->yOffset = yOff[i];
	pin[i]->x = x + pin[i]->xOffset;
	pin[i]->y = y + pin[i]->yOffset;
  }
       
  SaveType ("RotaryDip");   
  lastDip = -1;
}
ShiftRegister::ShiftRegister(int _x, int _y, Component * _diagram): ConnectedComponent(_x,_y,_diagram)
{ 
  char names[][MAX_SHIFTREGISTER_PINS] = {"VCC", "A", "SER", "Output Disable", "RCLK", "SRCLK", "SRCLR",  "Qh",
                                            "B", "C",   "D",              "E",    "F",     "G",     "H", "GND"};
                                 
       
  int xOff[] = {15,53,91,130,165,205,242,278, 15, 53, 91,130,165,205,242,278};
  int yOff[] = { 0, 0, 0,  0,  0,  0,  0,  0,109,109,109,109,109,109,109,109};
  pinSelected = false;
  shiftValue = 0;
  lastSRCLK = 0;
  x = _x;
  y = _y;
  clearTheText = false; 
  
  for (int i=0; i<MAX_SHIFTREGISTER_PINS; i++)
  {
    pin[i] = new Pin(this);
  	pin[i]->SetName ( names[i] );
  	pin[i]->xOffset = xOff[i];
  	pin[i]->yOffset = yOff[i];
	pin[i]->x = x + pin[i]->xOffset;
	pin[i]->y = y + pin[i]->yOffset;
  }
       
  SaveType ("ShiftRegister");   
}
Resistor::Resistor(int _x, int _y, int _resistance, Component * _diagram):ConnectedComponent(_x,_y,_diagram)
{ 
  input = new Pin(this);
  output = new Pin(this);
  input->xOffset = 0;
  input->yOffset = 5;
  output->xOffset = 67;
  output->yOffset = 5; 
  x = _x;
  y = _y;
  input->x = x + input->xOffset;
  input->y = y + input->yOffset;    
  output->x = x + output->xOffset;
  output->y = y + output->yOffset; 
  input->SetName ("Left");
  output->SetName ("Right");  
  SaveType ("Resistor");  
  resistance = _resistance;  
  input->constValue.resistance = resistance;
  input->value.resistance = resistance;    
  output->constValue.resistance = resistance;
  output->value.resistance = resistance; 
  
  // Create a virtual connections between input and output.
  connections[numConnections++] = new Connection ( input, output); 
}
示例#5
0
  bool generate() {
    for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
         ++it) {
      std::string enumcode;
      go::GenEnum(**it, &enumcode);
      if (!SaveType(**it, enumcode, false)) return false;
    }

    for (auto it = parser_.structs_.vec.begin();
         it != parser_.structs_.vec.end(); ++it) {
      std::string declcode;
      go::GenStruct(**it, &declcode);
      if (!SaveType(**it, declcode, true)) return false;
    }

    return true;
  }
// 14 Digitals plus 6 analogs can also be used
ArduinoComponent::ArduinoComponent(int _x, int _y, Component * _diagram): ConnectedComponent(_x, _y, _diagram)
{ 
  char name[] = "d00";
  x = _x;
  y = _y;
  gnd = new Pin(this);
  gnd->constValue.value = 0;
  gnd->constValue.resistance = 0;
  gnd->xOffset = 310;
  gnd->yOffset = 319;
  gnd->x = x + gnd->xOffset;
  gnd->y = y + gnd->yOffset;
  gnd->SetName ("gnd");
  power = new Pin (this);
  power->constValue.value = 1;
  power->constValue.resistance=0;
  power->xOffset = 278;
  power->yOffset = 319;
  power->x = x + power->xOffset;
  power->y = y + power->yOffset;
  power->SetName ("5v");
  for (int i=0; i<MAX_DIGITAL_VALUES; i++)
  {
    d[i] = new Pin(this);  
    name[1] = '0' + (i/10);
    name[2] = '0' + (i%10);
    d[i]->SetName (&name[0]);
  }  
  
  digitalValues[0]  = (digitalInfo) {440, 11,false};
  digitalValues[1]  = (digitalInfo) {424, 11,false};
  digitalValues[2]  = (digitalInfo) {408, 11,false};
  digitalValues[3]  = (digitalInfo) {392, 11,false};
  digitalValues[4]  = (digitalInfo) {376, 11,false};
  digitalValues[5]  = (digitalInfo) {360, 11,false};
  digitalValues[6]  = (digitalInfo) {344, 11,false};
  digitalValues[7]  = (digitalInfo) {326, 11,false};
  digitalValues[8]  = (digitalInfo) {300, 11,false};
  digitalValues[9]  = (digitalInfo) {284, 11,false};
  digitalValues[10] = (digitalInfo) {268, 11,false};
  digitalValues[11] = (digitalInfo) {252, 11,false};
  digitalValues[12] = (digitalInfo) {236, 11,false};
  digitalValues[13] = (digitalInfo) {220, 11,false};
  digitalValues[14] = (digitalInfo) {359,320,false}; 
  digitalValues[15] = (digitalInfo) {375,320,false}; 
  digitalValues[16] = (digitalInfo) {391,320,false}; 
  digitalValues[17] = (digitalInfo) {407,320,false}; 
  digitalValues[18] = (digitalInfo) {423,320,false}; 
  digitalValues[19] = (digitalInfo) {439,320,false}; 
  
  for (int i=0; i<MAX_DIGITAL_VALUES; i++)
  {
    d[i]->x = digitalValues[i].x+x;
    d[i]->y = digitalValues[i].y+y;
  }
  SaveType ("Arduino");
}
示例#7
0
 bool generateStructs() {
   for (auto it = parser_.structs_.vec.begin();
        it != parser_.structs_.vec.end(); ++it) {
     auto &struct_def = **it;
     std::string declcode;
     GenStruct(struct_def, &declcode);
     if (!SaveType(struct_def, declcode, true)) return false;
   }
   return true;
 }
示例#8
0
 bool generateEnums() {
   for (auto it = parser_.enums_.vec.begin(); it != parser_.enums_.vec.end();
        ++it) {
     auto &enum_def = **it;
     std::string enumcode;
     GenEnum(enum_def, &enumcode);
     if (!SaveType(enum_def, enumcode, false)) return false;
   }
   return true;
 }
示例#9
0
文件: opsave.cpp 项目: ploki/darkflow
OpSave::OpSave(Process *parent) :
    Operator(OP_SECTION_ASSETS, QT_TRANSLATE_NOOP("Operator", "Save"), Operator::All, parent),
    m_directory(new OperatorParameterDirectory("directory", tr("Target directory"), m_process->baseDirectory(), "", this)),
    m_fileType(new OperatorParameterDropDown("fileType", tr("File type"), this, SLOT(selectType(int)))),
    m_fileTypeValue(SaveFITS),
    m_backup(new OperatorParameterDropDown("backup", tr("Backup"), this, SLOT(selectBackup(int))))
{
    m_fileType->addOption(DF_TR_AND_C(SaveTypeStr[SaveFITS]), SaveFITS, true);
    m_fileType->addOption(DF_TR_AND_C(SaveTypeStr[SaveTIFF]), SaveTIFF);
    m_fileType->addOption(DF_TR_AND_C(SaveTypeStr[SaveJPEG]), SaveJPEG);

    m_backup->addOption(DF_TR_AND_C("No"), false, true);
    m_backup->addOption(DF_TR_AND_C("Yes"), true);

    addParameter(m_directory);
    addParameter(m_fileType);
    addParameter(m_backup);
    addInput(new OperatorInput(tr("Images"), OperatorInput::Set, this));
}

OpSave *OpSave::newInstance()
{
    return new OpSave(m_process);
}

OperatorWorker *OpSave::newWorker()
{
    return new WorkerSave(m_directory->currentValue(), m_fileTypeValue, m_backupValue, m_thread, this);
}

void OpSave::selectType(int v)
{
    if ( m_fileTypeValue != v ) {
        m_fileTypeValue = SaveType(v);
        setOutOfDate();
    }
}

void OpSave::selectBackup(int v)
{
    if ( m_backupValue != !!v ) {
        m_backupValue = !!v;
        //no need to invalidate process
    }
}