Ejemplo n.º 1
0
_HYEvent*	generateContextPopUpEvent (long objID, long locH, long locV)
{
	_String eventClass (_hyContextPopUp),
			eventData  (objID);
	eventData = eventData & ','& _String (locH) & ',' & _String (locV);
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 2
0
void	warnError (long errCode)
{
	if (errCode == -108)
		warnError (DecodeError (errCode)&_String(" Exiting..."));
	else
		WarnError (DecodeError (errCode)&_String(" Exiting..."));
}
Ejemplo n.º 3
0
_HYEvent*	generateTableResizeCEvent (long objID, long index, long shift)
{
	_String eventClass (_hyTableResizeCEvent),
			eventData  (objID);
	eventData = eventData & ','& _String (index) & ','& _String (shift);
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 4
0
_HYEvent*	generateTablePullDownEvent (long objID, long index, long location)
{
	_String eventClass (_hyTablePullDownEvent),
			eventData  (objID);
	eventData = eventData & ','& _String (index) & ',' & _String (location);
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 5
0
void    SetStatusBarValue (long l,_Parameter max, _Parameter rate)
{
    _tHYPHYDone = l;
    _tHYPHYCurrentStatus   = _String ("LF Optimization. Value=") & _String (max) &", "&_String (rate) & " evals/sec.";
    _tHYPHYValue = max;
    yieldCPUTime();
}
Ejemplo n.º 6
0
//__________________________________________________________________________________
void mpiBgmLoop (int rank, int size)
{
    long        senderID    = 0;
    _String *   resStr      = nil;

    ReportWarning (_String ("MPI Node:") & (long)rank & " is ready for MPIBgmCacheNodeScores tasks");

    // receive serialized Bgm
    _String* theMessage = MPIRecvString (-1, senderID);

    while (theMessage->sLength) {
        _ExecutionList  exL (*theMessage);
        _PMathObj       res = exL.Execute();    // should send this process into CacheNodeScores()

        resStr = res ? (_String*)res->toStr() : new _String ("0");
        ReportWarning (_String ("MPI Node: ") & (long)rank & " executed HBL with result:\n" & resStr);

        if (bgmNamesList.lLength < 1) {
            _String errMsg ("Malformed HBL. No valid BGM has been defined.\n");
            FlagError (errMsg);
            break;
        }
    }

    DeleteObject (theMessage);
}
Ejemplo n.º 7
0
 bool    RegisterChangeListenerForDataFilter (long const index, BaseRef listener) {
     
   //StringToConsole(_String("RegisterChangeListenerForDataFilter ") & index & " " & (long)listener & "\n");
     
   if (_data_filters.IsValidIndex (index)) {
     
     if (dynamic_cast <_LikelihoodFunction*> (listener)) {
       _List * current_listeners = (_List *)_data_filter_listeners.GetDataByKey ((BaseRef)index);
       if (!current_listeners) {
         current_listeners = new _List;
         _data_filter_listeners.Insert ((BaseRef)index, (long)current_listeners, false, false);
       }
       
       if (current_listeners->_SimpleList::Find((long)listener) < 0L) {
         (*current_listeners) << listener;
       }
       return true;
       
     }
     
     
     WarnError (_String("Not a supported listener type in call to ") & _String (__PRETTY_FUNCTION__));
     
     
   }
   
   return false;
 }
Ejemplo n.º 8
0
//__________________________________________________________________________________
void mpiOptimizerLoop (int rank, int size)
{
	long		 senderID = 0;
			
	ReportWarning (_String ("MPI Node:") & (long)rank & " is ready for MPIParallelOptimizer tasks");
				
	if (mpiPartitionOptimizer)
		ReportWarning (_String("MPI Partitions mode"));
	
	//printf ("Node %d waiting for a string\n", rank);
	_String* theMessage = MPIRecvString (-1,senderID);
	while (theMessage->sLength)
	{
		if (theMessage->beginswith ("#NEXUS"))
		{
			ReadDataSetFile (nil,true,theMessage);
			if (likeFuncNamesList.lLength!=1)
			{
				_String errMsg ("Malformed MPI likelihood function paraller optimizer startup command. No valid LF has been defined.n\n\n");
				FlagError (errMsg);
				break;						
			}
			
			// send back the list of independent variables
			
			_LikelihoodFunction * theLF = (_LikelihoodFunction*)likeFuncList (0);
			
			if (mpiParallelOptimizer && theLF->GetCategoryVars().lLength)
			{
				_String errMsg ("Likelihood functions spawned off to slave MPI nodes can't have category variables.n\n\n");
				FlagError (errMsg);
				break;						
			}
			
			_SimpleList* ivl = & theLF->GetIndependentVars();
			
			_String		 variableSpec (128L, true);
			
			(variableSpec) << LocateVar(ivl->lData[0])->GetName();

			for (long kk = 1; kk < ivl->lLength; kk++)
			{
				(variableSpec) << ';';
				(variableSpec) << LocateVar(ivl->lData[kk])->GetName();	
			}
			
			ReportWarning 		  (variableSpec);
			MPISendString		  (variableSpec,senderID);
			theLF->PrepareToCompute();
			theLF->MPI_LF_Compute (senderID, mpiPartitionOptimizer);
			theLF->DoneComputing();
			PurgeAll (true);
		}
		DeleteObject (theMessage);
		theMessage = MPIRecvString (-1,senderID);
	}	
	DeleteObject (theMessage);		
}
Ejemplo n.º 9
0
int USPiInitialize (void)
{
	assert (s_pLibrary == 0);
	s_pLibrary = (TUSPiLibrary *) malloc (sizeof (TUSPiLibrary));
	assert (s_pLibrary != 0);

	DeviceNameService (&s_pLibrary->NameService);
	DWHCIDevice (&s_pLibrary->DWHCI);
	s_pLibrary->pEth0 = 0;

	if (!DWHCIDeviceInitialize (&s_pLibrary->DWHCI))
	{
		LogWrite (FromUSPi, LOG_ERROR, "Cannot initialize USB host controller interface");

		_DWHCIDevice (&s_pLibrary->DWHCI);
		_DeviceNameService (&s_pLibrary->NameService);
		free (s_pLibrary);
		s_pLibrary = 0;

		return 0;
	}

	s_pLibrary->pUKBD1 = (TUSBKeyboardDevice *) DeviceNameServiceGetDevice (DeviceNameServiceGet (), "ukbd1", FALSE);

	s_pLibrary->pUMouse1 = (TUSBMouseDevice *) DeviceNameServiceGetDevice (DeviceNameServiceGet (), "umouse1", FALSE);

	s_pLibrary->pMIDI1 = (TUSBMIDIDevice *) DeviceNameServiceGetDevice (DeviceNameServiceGet (), "umidi1", FALSE);

	for (unsigned i = 0; i < MAX_DEVICES; i++)
	{
		TString DeviceName;
		String  (&DeviceName);
		StringFormat (&DeviceName, "umsd%u", i+1);

		s_pLibrary->pUMSD[i] = (TUSBBulkOnlyMassStorageDevice *)
			DeviceNameServiceGetDevice (DeviceNameServiceGet (), StringGet (&DeviceName), TRUE);

		_String  (&DeviceName);
	}

	s_pLibrary->pEth0 = (TSMSC951xDevice *) DeviceNameServiceGetDevice (DeviceNameServiceGet (), "eth0", FALSE);

	for (unsigned i = 0; i < MAX_DEVICES; i++)
	{
		TString DeviceName;
		String  (&DeviceName);
		StringFormat (&DeviceName, "upad%u", i+1);

		s_pLibrary->pUPAD[i] = (TUSBGamePadDevice *)
			DeviceNameServiceGetDevice (DeviceNameServiceGet (), StringGet (&DeviceName), FALSE);

		_String  (&DeviceName);
	}

	LogWrite (FromUSPi, LOG_DEBUG, "USPi library successfully initialized");

	return 1;
}
Ejemplo n.º 10
0
//__________________________________________________________________________________
void mpiOptimizerLoop (int rank, int size)
{
    long		 senderID = 0;

    ReportWarning (_String ("[MPI] Node:") & (long)rank & " is ready for MPIParallelOptimizer tasks");

    if (hyphyMPIOptimizerMode == _hyphyLFMPIModePartitions)
        ReportWarning ("[MPI] MPI Partitions mode");

    //printf ("Node %d waiting for a string\n", rank);
    _String* theMessage = MPIRecvString (-1,senderID);
    while (theMessage->sLength)
    {
        if (theMessage->beginswith ("#NEXUS"))
        {
            //ReportWarning (*theMessage);
            ReadDataSetFile (nil,true,theMessage);
            if (likeFuncNamesList.lLength!=1)
            {
                FlagError ("[MPI] Malformed MPI likelihood function paraller optimizer startup command. Exactly ONE valid LF must be defined.n\n\n");
                break;
            }

            // send back the list of independent variables

            _LikelihoodFunction * theLF = (_LikelihoodFunction*)likeFuncList (0);
            if (hyphyMPIOptimizerMode == _hyphyLFMPIModeREL && theLF->CountObjects (4))
            {
                FlagError (_String("[MPI] Likelihood functions spawned off to slave MPI nodes can't have category variables.n\n\n"));
                break;
            }

            _SimpleList* ivl = & theLF->GetIndependentVars();
            _String		 variableSpec (128L, true);

            (variableSpec) << LocateVar(ivl->lData[0])->GetName();

            for (long kk = 1; kk < ivl->lLength; kk++)
            {
                (variableSpec) << ';';
                (variableSpec) << LocateVar(ivl->lData[kk])->GetName();
            }
            variableSpec.Finalize();
            ReportWarning 		  (_String("[MPI] Sending back the following variable list\n") & variableSpec);
            MPISendString		  (variableSpec,senderID);
            theLF->PrepareToCompute();
            theLF->MPI_LF_Compute (senderID, !(hyphyMPIOptimizerMode == _hyphyLFMPIModeREL ||
                                               hyphyMPIOptimizerMode  == _hyphyLFMPIModeSiteTemplate));
            theLF->DoneComputing();
            PurgeAll (true);
        }
        DeleteObject (theMessage);
        theMessage = MPIRecvString (-1,senderID);
    }
    DeleteObject (theMessage);
}
Ejemplo n.º 11
0
_HYEvent*	generateScrollEvent (int h,int v,long objID)
{
	_String eventClass (_hyScrollingEvent),
			eventData ((long)h);
	eventData = eventData & ','& _String ((long)v);
	if (objID>=0)
		eventData = _String (objID)&','&eventData;
		
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 12
0
void	SetStatusBarValue (long l,_Parameter max, _Parameter rate)
{
	#ifdef __HYPHYMPI__
		if (_hy_mpi_node_rank > 0) return;
	#endif

	hyphyConsoleWindow->percentDone = l;
	if (max<=0.0)
		hyphyConsoleWindow->action   = _String ("LF Optimization. Value=") & _String (max) &", "&_String (rate) & " evals/sec.";
	hyphyConsoleWindow->_PaintStatusBar();
}
Ejemplo n.º 13
0
_HYEvent*	generateTextEditChangeEvent (long objID, long mouseOrKey)
{
	_String eventClass (_hyTextEditChange),
			eventData  (objID);
	eventData = eventData & ','& _String (mouseOrKey);
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 14
0
_PMathObj  _Variable::Compute (void) // compute or return the value
{
    if (varFormula == nil) { // no formula, just return the value
        if (varValue) {
            return varValue->Compute();
        }

        if (varFlags & HY_VARIABLE_NOTSET) {
            ReportWarning (_String ("Variable '") & *GetName() & "' was not initialized prior to being used");
        }

        varValue =  new _Constant(theValue);
    } else {
        //printf ("Recomputing value of %s\n", theName->sData);
        if (useGlobalUpdateFlag) {
            if ((varFlags & HY_DEP_V_COMPUTED) && varValue) {
                return varValue;
            } else if (varFormula->HasChanged()||!varValue) {
                DeleteObject (varValue);
                varValue = (_PMathObj)varFormula->Compute()->makeDynamic();
            }

            varFlags |= HY_DEP_V_COMPUTED;
        } else if (varFormula->HasChanged()||!varValue) {
            DeleteObject (varValue);
            varValue = (_PMathObj)varFormula->Compute()->makeDynamic();
        }

    }

    return varValue;
}
Ejemplo n.º 15
0
void _HYPlatformGraphicPane::_DrawPicRes (_HYRect& r, long id)
{
	PicHandle  aPic = GetPicture (id);
	if (aPic)
	{
		Rect		aRect = HYRect2Rect (r);
		PictInfo	pInfo; 
		GetPictInfo (aPic,&pInfo,0,0,0,0);
		
		if (aRect.right-aRect.left<=0)
			r.right = aRect.right = aRect.left + pInfo.sourceRect.right - pInfo.sourceRect.left;

		if (aRect.bottom-aRect.top<=0)
			r.bottom = aRect.bottom = aRect.top + pInfo.sourceRect.bottom - pInfo.sourceRect.top;

		DrawPicture (aPic, &aRect);
		
		ReleaseResource ((Handle)aPic);
	}
	else
	{
		_String errMsg = _String ("No picture resource with ID ") & id;
		ReportWarning (errMsg);
	}
}		
Ejemplo n.º 16
0
_HYEvent*	generateListDblClickEvent (long objID, long newSel)
{
	_String eventClass (_hyListDblClickEvent),
			eventData (objID);
	eventData = eventData & ','& _String (newSel);
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 17
0
_HYEvent*	generateTableEditCellEvent (long objID, long index)
{
	_String eventClass (_hyTableEditCellEvent),
			eventData  (objID);
	eventData = eventData & ','& _String (index);
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 18
0
_HYEvent*	generateButtonPushEvent (long objID, long newSel)
{
	_String eventClass (_hyButtonPushEvent),
			eventData (objID);
	eventData = eventData & ','& _String (newSel);
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 19
0
_String  _Trie::RetrieveKeyByPayload (const long key){
    long key_index = payload.Find (key);
    if (key_index >= 0) {
        _SimpleList parent_indices,
                    traversal_history;
        long keyer = key_index;
        do{
            parent_indices << keyer;
            keyer = parents.lData[keyer];
        }
        while (keyer > 0);
        parent_indices << 0;
        parent_indices.Flip();
        
        
        for (long i = 0; i < parent_indices.lLength-1; i++) {
            traversal_history << parent_indices.lData[i];
            traversal_history << (((_SimpleList**)lData)[parent_indices.lData[i]])->FindStepping (parent_indices.lData[i+1],2,1)-1;
        }
        traversal_history << key_index;
        traversal_history << 0L;
        _String alph = Alphabet();
        return _String(RetrieveStringFromPath(traversal_history, &alph));
        
    }
    return empty;
}
Ejemplo n.º 20
0
_HYEvent*	generateMenuSelChangeEvent (long objID, long newSel)
{
	_String eventClass (_hyMenuSelChangeEvent),
			eventData (objID);
	eventData = eventData & ','& _String (newSel);
	return	new _HYEvent (eventClass,eventData);
}
Ejemplo n.º 21
0
void    ListToPopUpMenu (_List& menuOptions)
{
    lastPopupFactory = new GtkItemFactoryEntry [menuOptions.lLength];
    checkPointer (lastPopupFactory);

    long         sepCounter = 0;

    for (long counter=0; counter<menuOptions.lLength; counter++) {
        _String *postItem = (_String*)(menuOptions(counter)),
                 * pathID   = new _String("/Popup/"),
        * itemType = new _String;

        lastPopupFactory[counter].accelerator    = NULL;
        lastPopupFactory[counter].callback_action = counter;
        lastPopupFactory[counter].callback       = G_CALLBACK(hyphy_popup_menu_callback);
        if (*postItem==_String("SEPARATOR")) {
            *pathID = *pathID & "sep" & (sepCounter++);
            *itemType = "<Separator>";
        } else {
            *pathID = *pathID & *postItem;
            *itemType = "<Item>";
        }
        lastPopupFactory[counter].path = pathID->sData;
        lastPopupFactory[counter].item_type = itemType->sData;
        lastPopupMenuItemStrings << pathID;
        lastPopupMenuItemStrings << itemType;

        DeleteObject (pathID);
        DeleteObject (itemType);
    }
}
Ejemplo n.º 22
0
TString *USBStandardHubGetDeviceNames (TUSBDevice *pDevice)
{
	assert (pDevice != 0);

	TString *pResult = (TString *) malloc (sizeof (TString));
	assert (pResult != 0);
	String (pResult);

	for (unsigned nSelector = DeviceNameVendor; nSelector < DeviceNameUnknown; nSelector++)
	{
		TString *pName = USBDeviceGetName (pDevice, (TDeviceNameSelector) nSelector);
		assert (pName != 0);

		if (StringCompare (pName, "unknown") != 0)
		{
			if (StringGetLength (pResult) > 0)
			{
				StringAppend (pResult, ", ");
			}

			StringAppend (pResult, StringGet (pName));
		}

		_String (pName);
		free (pName);
	}

	if (StringGetLength (pResult) == 0)
	{
		StringSet (pResult, "unknown");
	}

	return pResult;
}
Ejemplo n.º 23
0
void _HYModelWindow::_SetMenuBar(void)
{
    if (menu_items && !gtk_item_factory_get_item(menu_items,"<HY_WINDOW>/Model")) {
        gtk_item_factory_delete_item (menu_items, "<HY_WINDOW>/File/Save");
        gtk_item_factory_create_items (menu_items,  sizeof (hyphy_parameter_model_window_menu) / sizeof (hyphy_parameter_model_window_menu[0]),
                                       hyphy_parameter_model_window_menu, this);

        GtkMenu * fileMenu = GTK_MENU (gtk_item_factory_get_widget (menu_items, "<HY_WINDOW>/File"));
        gtk_menu_reorder_child (fileMenu, gtk_item_factory_get_item (menu_items, "<HY_WINDOW>/File/Save"), 0);

        for (long k=0; k<rateOptions.lLength; k++) {
            _String *thisItem = (_String*)rateOptions (k),
                     chopped,
                     type = "<CheckItem>";

            GtkItemFactoryEntry aProcEntry = {NULL,NULL,(GtkItemFactoryCallback)hyphy_menu_item_callback,HY_MDL_WIN32_MENU_BASE+100+k,type.sData};
            chopped = _String("/Model/Rate variation/")&*thisItem;
            aProcEntry.path = chopped.sData;

            gtk_item_factory_create_items (menu_items,  1, &aProcEntry, this);
        }
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget_by_action(menu_items,HY_MDL_WIN32_MENU_BASE+100+rateChoice)),
                                       true);

        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Copy"),  true);
        gtk_widget_set_sensitive(gtk_item_factory_get_widget (menu_items,"<HY_WINDOW>/Edit/Select All"),  true);
    }
}
Ejemplo n.º 24
0
_String	_HYColor::HTMLColor (void)
{
	char out[7];
	
	sprintf (out, "%x%x%x", R, G, B);
	
	return _String (out);
}
Ejemplo n.º 25
0
void test_at()
{
   const char* _Hello = "Hello";
   ev4::string<> _String(_Hello);
   
   for (std::size_t i = 0; i< _String.size(); ++i) std::cout << _String.at(i);

   std::cout << std::endl;
}
Ejemplo n.º 26
0
void test_equal()
{
   ev4::string<> _String("String 1");
   ev4::string<> _String2("String 2");
   ev4::string<> _String3("String 1");

   std::cout << (_String == _String3) << std::endl;
   std::cout << (_String == _String2) << std::endl;
}
Ejemplo n.º 27
0
void test_assign()
{
   ev4::string<> _String("Jarret");
   ev4::string<> _String2("Nate");

   _String = _String2;

   std::cout << _String << std::endl;
}
Ejemplo n.º 28
0
void test_add_asign()
{
   ev4::string<> _String("Hello ");
   ev4::string<> _String2("World");

   _String += _String2;

   std::cout << _String << std::endl;
}
Ejemplo n.º 29
0
 unsigned long  CountObjectsByType (const long type) {
   switch (type) {
     case HY_BL_DATASET_FILTER:
       return _data_filters.countitems();
       break;
   }
   WarnError (_String("Called ") & __PRETTY_FUNCTION__ & " with an unsupported type");
   return 0UL;
 }
Ejemplo n.º 30
0
//________________________________________________________
Ptr     ProcureIconResource (long id)
{
    long cid = loadedXPMs.Find ((BaseRef)id);
    if (cid < 0) {
        _String picFileName = libDirectory & _String("GTKResources/") & id & ".png";
        GError * pixBufError = nil;
        GdkPixbuf*  thePixMap = gdk_pixbuf_new_from_file  (picFileName.sData, &pixBufError);
        if (!thePixMap) {
            picFileName = _String("Failed to load a pixbuf from file. GTK Error ") & pixBufError -> message;
            WarnError (picFileName);
            g_error_free (pixBufError);
            return nil;
        }
        cid = loadedXPMs.Insert ((BaseRef)id, (long)thePixMap);
    }

    return (Ptr)loadedXPMs.GetXtra(cid);
}