Example #1
0
/*------------------------------------------------------------------*/
void AzRgforest::optimize_resetTarget()
{
    clock_t b_time;
    time_begin(&b_time);

    int t_num = ens->size();

    AzBytArr s("Calling optimizer with ");
    s.cn(t_num);
    s.c(" trees and ");
    s.cn(l_num);
    s.c(" leaves");
    AzTimeLog::print(s, out);

    opt->update(data, ens, &v_p);
    resetTarget();

    int tx;
    for (tx = 0; tx < t_num; ++tx) {
        ens->tree_u(tx)->removeSplitAssessment(); /* since weights changed */
    }

    isOpt = true;

    time_end(b_time, &opt_time);
}
CaosIsp::CaosIsp(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::CaosIsp)
{

  Settings settings(Settings::global());
  CLink * device;
  CFont::init();

  QCoreApplication::setOrganizationName("CoActionOS, Inc");
  QCoreApplication::setOrganizationDomain("coactionos.com");
  QCoreApplication::setApplicationName("CoActionOS-ISP");
  QCoreApplication::setApplicationVersion(COACTIONOS_ISP_VERSION);

  ui->setupUi(this);
  CNotify::setUpdateObjects(ui->statusBar, 0);

  link_set_debug(1);

  device = ui->connectWidget->clink();

  QFile file(":/data/CStyle.css");
  if( file.open(QFile::ReadOnly)) {
      QString StyleSheet = QLatin1String(file.readAll());
      qApp->setStyleSheet(StyleSheet);
    }

  ui->tabWidget->setTabText(TAB_INSTALLER, CFont::iconDownloadAlt());
  ui->tabWidget->setTabText(TAB_TERMINAL, CFont::iconEdit());
  ui->tabWidget->setTabText(TAB_PREFERENCES, CFont::iconCogs());
  ui->tabWidget->setTabEnabled(TAB_LABEL, false);

  ui->installTab->setLink(device);
  ui->terminalTab->setLink(device);
  ui->preferencesTab->setLink(device);

  connect(device, SIGNAL(linked(bool)), ui->installTab, SLOT(connected(bool)));
  connect(ui->installTab, SIGNAL(pauseTerminal(bool)), ui->terminalTab, SLOT(setPaused(bool)));
  connect(ui->installTab, SIGNAL(completed()), this, SLOT(installCompleted()));

  connect(ui->terminalTab, SIGNAL(resetTarget()), ui->installTab, SLOT(resetTarget()));
  connect(ui->terminalTab, SIGNAL(showPreferences()), this, SLOT(showPreferences()));

  ui->tabWidget->setCurrentIndex( settings.currentTab().toInt() );
  on_tabWidget_currentChanged(settings.currentTab().toInt());
}
Example #3
0
// Init some variables & UI-elements on app start
void MainWindow::initValues()
{
   appVersion = "20151103.02";      // App Version
   appName = "DirGister";           // App Name

   this->setWindowTitle(appName + " ("+ appVersion +")");


   // TAB: main
   //
   connect(ui->bt_selectSource, SIGNAL(clicked()), this, SLOT(setSourceFolder()));
   connect(ui->bt_selectTarget, SIGNAL(clicked()), this, SLOT(setTargetFolder()));
   connect(ui->bt_generateIndex, SIGNAL(clicked()), this, SLOT(userTriggeredGeneration()));

   ui->le_sourceFolder->setDisabled(true);
   ui->le_targetFolder->setDisabled(true);
   ui->rb_writeLog->setText("Enable log file creation");
   ui->l_logDescription->setText("<font color='grey'><i>The target folder will contain the generated log</i></font>");

    // reset source
   QPixmap pixmap(":/images/fa-trash-o_128_0_000000_none.png");
   QIcon ButtonIcon(pixmap);
   ui->tb_resetSource->setIcon(ButtonIcon);
   connect(ui->tb_resetSource, SIGNAL(clicked()), this, SLOT(resetSrc()));
   //ui->tb_resetSource->setIconSize(pixmap.rect().size());
   ui->tb_resetTarget->setIcon(ButtonIcon);
   connect(ui->tb_resetTarget, SIGNAL(clicked()), this, SLOT(resetTarget()));

   QPixmap pixmap4GenerateButton(":/images/fa-pencil_128_0_000000_none.png");
   QIcon ButtonIcon4GenerateButton(pixmap4GenerateButton);
   ui->bt_generateIndex->setIcon(ButtonIcon4GenerateButton);

   // TAB: about
   //
   ui->l_appTitle->setText(appName);
   ui->l_appVersion->setText(appVersion);
   ui->pte_aboutText->insertPlainText ("DirGister is a multi-platform directory indexer with HTML output written by Florian Poeck.\n\nHow it works:\n- You define a source folder and a target folder\n- It scans the source folder and\n- writes a html-based browseable index into the target-folder\n\n\nDeveloped under MIT license.");
   // Issues Link
   ui->l_linkIssues->setText("<a href=\"https://github.com/yafp/dirgister/issues\">Issues</a>");
   ui->l_linkIssues->setTextFormat(Qt::RichText);
   ui->l_linkIssues->setTextInteractionFlags(Qt::TextBrowserInteraction);
   ui->l_linkIssues->setOpenExternalLinks(true);
   // Wiki Link
   ui->l_linkWiki->setText("<a href=\"https://github.com/yafp/dirgister/wiki\">Wiki</a>");
   ui->l_linkWiki->setTextFormat(Qt::RichText);
   ui->l_linkWiki->setTextInteractionFlags(Qt::TextBrowserInteraction);
   ui->l_linkWiki->setOpenExternalLinks(true);
   // Source Link
   ui->l_linkSource->setText("<a href=\"https://github.com/yafp/dirgister\">Source</a>");
   ui->l_linkSource->setTextFormat(Qt::RichText);
   ui->l_linkSource->setTextInteractionFlags(Qt::TextBrowserInteraction);
   ui->l_linkSource->setOpenExternalLinks(true);

   // set default-tab
   ui->tabWidget->setCurrentIndex(0);
}
Example #4
0
uiDrawContext *newContext(ID2D1RenderTarget *rt)
{
	uiDrawContext *c;

	c = uiNew(uiDrawContext);
	c->rt = rt;
	initStates(c);
	resetTarget(c->rt);
	return c;
}
Example #5
0
int QDeclarativeDrag::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 8)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QGraphicsObject**>(_v) = target(); break;
        case 1: *reinterpret_cast< Axis*>(_v) = axis(); break;
        case 2: *reinterpret_cast< qreal*>(_v) = xmin(); break;
        case 3: *reinterpret_cast< qreal*>(_v) = xmax(); break;
        case 4: *reinterpret_cast< qreal*>(_v) = ymin(); break;
        case 5: *reinterpret_cast< qreal*>(_v) = ymax(); break;
        case 6: *reinterpret_cast< bool*>(_v) = active(); break;
        case 7: *reinterpret_cast< bool*>(_v) = filterChildren(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setTarget(*reinterpret_cast< QGraphicsObject**>(_v)); break;
        case 1: setAxis(*reinterpret_cast< Axis*>(_v)); break;
        case 2: setXmin(*reinterpret_cast< qreal*>(_v)); break;
        case 3: setXmax(*reinterpret_cast< qreal*>(_v)); break;
        case 4: setYmin(*reinterpret_cast< qreal*>(_v)); break;
        case 5: setYmax(*reinterpret_cast< qreal*>(_v)); break;
        case 7: setFilterChildren(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 0: resetTarget(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #6
0
void Camera::reset(const ego_mesh_t *mesh)
{
    // Defaults.
    _trackLevel   = 0.0f;
    _zoom         = CAM_ZOOM_AVG;
    _zadd = CAM_ZADD_AVG;
    _zaddGoto = CAM_ZADD_AVG;
    _zGoto = CAM_ZADD_AVG;
    _turnZ_radians = -Ego::Math::piOverFour<float>();
    _turnZAdd = 0.0f;
    _roll = 0.0f;

    // Derived values.
    _center[kX]     = mesh->gmem.edge_x * 0.5f;
    _center[kY]     = mesh->gmem.edge_y * 0.5f;
    _center[kZ]     = 0.0f;

	_trackPos = _center;
	_position = _center;

    _position[kX] += _zoom * std::sin(_turnZ_radians);
	_position[kY] += _zoom * std::cos(_turnZ_radians);
    _position[kZ] += CAM_ZADD_MAX;

    _turnZ_turns = RadiansToTurns(_turnZ_radians);
    _ori.facing_z = TurnsToFacing(_turnZ_turns) ;

    // Get optional parameters.
    _swing = _options.swing;
    _swingRate = _options.swingRate;
    _swingAmp = _options.swingAmp;
    _turnMode = _options.turnMode;

    // Make sure you are looking at the players.
    resetTarget(mesh);
}
Example #7
0
struct Node* readFile(const char *filename, const char *target,	const char *fPath) {
	//Read in remodelfile and check for new target
	char lineBuf[2048];
	struct Node* root = NULL;
	FILE *file = fopen(filename, "r");
	if (!file) {
		printf("Could not open remodelfile\n");
		abort();
	} else {
		//Read first line
		if (readLine(file, lineBuf, sizeof(lineBuf)) != 0)
			return NULL;

		while (1) {
			struct Node* ptr = createSubTree(file);
			if (ptr == NULL)
				break;

			if (root == NULL)
				root = ptr;
			else {
				addSubTreeToParent(ptr, root);
			}
		}
		//Change target to one given in command argument
		if (target != NULL)
			resetTarget(target, root);

		char *dirName = ".remodel";
		char *fileName = ".remodel/md5.txt";
		struct stat st;


		if (stat(dirName, &st) == 0) {
			printf(".remodel is present\n");
		} else {
			system("mkdir .remodel");
		}

		if (stat(fileName, &st) == 0) {
			printf(".remodel/md5.txt is present\n");
			FILE *cmd = popen("md5sum -c .remodel/md5.txt", "r");
			char result[2048];
			memset(result, 0, sizeof(result));
			//Set StatusFlag for all to 1
			setStatus(root);
			int namel = 0;
			while (fgets(result, sizeof(result), cmd) != NULL) {
				printf("%s\n", result);

				if (result != NULL) {

					char *sName = strrchr(result, '/');
					sName++;
					char *eName = strrchr(result, ':');
					namel = eName - sName;
					char nameValue[256];
					memset(nameValue, 0, sizeof(nameValue));
					memcpy(nameValue, sName, namel);

					char *fStatus = strchr(result, "F");
					//char *nFile = strchr(result, "N");
					if (fStatus != NULL) {
						if (strcmp(fStatus, "F") == 0) {
							if (treeSearch(root, nameValue) != 0)
								printf("Failed hash check");
						}
					}

				}

			}

			pclose(cmd);
			runCmd(root, fPath);
			counter = 0;
			runMD5(root, fPath);

		} else {

			runCmd(root, fPath);
			runMD5(root, fPath);

		}

		//free(st);
	}
	fclose(file);
	return root;
}
Example #8
0
void AITurretShape::_cleanupTargetAndTurret()
{
   _lostTarget();
   resetTarget();
}
Example #9
0
/* input: v_p */
void AzRgforest::initTarget(const AzDvect *v_y,
                            const AzDvect *v_fixed_dw)
{
    target.reset(v_y, v_fixed_dw);
    resetTarget();
}
/**********************************************************
 * Uses the flashloader to upload an application to 
 * the target. This function will first upload the 
 * flashloader, then communicate with the flashloader
 * to send the program. If successful the application
 * will be started when this function returns. 
 * 
 * @param verify
 *    If true, verify the application after it has been 
 *    written to flash
 **********************************************************/
void flashWithFlashloader(bool verify)
{
  uint32_t startTime = DWT->CYCCNT;
  uint32_t time;
  
#pragma section="fw_section"  
  int fwSize = __section_size("fw_section");
  
  printf("Preparing to upload firmware (%d bytes)\n", fwSize);
 
  /* Upload flashloader */
#pragma section="flashloader_section"  
  uploadFlashloader((uint32_t *)__section_begin("flashloader_section"), __section_size("flashloader_section")); 
  
  /* Check that flashloader is ready */
  verifyFlashloaderReady();
 


#if defined(SWD_FAST)
  
  /* Doing one Mass Erase is faster than erasing individual pages,
   * but it will case wear on all pages.
   * Only available on GG, LG, WG and ZG devices. */
  
  uint32_t part = readMem((uint32_t)&(DEVINFO->PART));
  uint32_t family = (part &  _DEVINFO_PART_DEVICE_FAMILY_MASK) >> _DEVINFO_PART_DEVICE_FAMILY_SHIFT;
  
  if ( family == _DEVINFO_PART_DEVICE_FAMILY_GG ||
       family == _DEVINFO_PART_DEVICE_FAMILY_LG ||
       family == _DEVINFO_PART_DEVICE_FAMILY_WG ||
       family == _DEVINFO_PART_DEVICE_FAMILY_ZG )
  {
    printf("Erasing entire flash\n");
    sendMassEraseCmd();      
  }
  else
  {
    erasePagesWithFlashloader(fwSize);
  }
#else 
  erasePagesWithFlashloader(fwSize);
#endif
      
  printf("Uploading firmware image\n");

  uploadImageToFlashloader(__section_begin("fw_section"), fwSize);
    
  /* Verify that the uploaded image is equal to the original */
  if ( verify ) 
  {
    if ( verifyFirmware((uint32_t *)__section_begin("fw_section"), fwSize) ) {
      printf("Application verified\n");
    } else {
      RAISE(SWD_ERROR_VERIFY_FW_FAILED);
    }
  }
  
  /* Calculate the total time spent flashing */
  time = DWT->CYCCNT - startTime;
  printf("Total time: %f s (%f kB/s)\n", (time/48e6), ((float)fwSize/1024) / (time/48e6));
  
  printf("Starting application\n");
  
  /* Reset target to start application */
  resetTarget();
}