Пример #1
0
 SplitState filterGraph(PartitionStack* ps, const GraphType& points,
                        const CellList& cells, int path_length)
 {
     // Would not normally go this low level, but it is important this is fast
     memset(&(mset.front()), 0, mset.size() * sizeof(mset[0]));
     edgesconsidered = 0;
     MonoSet monoset(ps->cellCount());
     debug_out(3, "EdgeGraph", "filtering: " << cells.size() << " cells out of " << ps->cellCount());
     if(path_length == 1) {
         for(int c : cells)
         {
             hashCellSimple(ps, points, monoset, c);
         }
     }
     else
     {
         MonoSet hitvertices(ps->domainSize());
         for(int c : cells)
         {
             hashRangeDeep(ps, points, monoset, hitvertices, ps->cellRange(c));
         }
         
         memset(&(msetspare.front()), 0, msetspare.size() * sizeof(msetspare[0]));
         hashRangeDeep2(ps, points, monoset, hitvertices.getMembers());
         for(int i : range1(mset.size())) {
             mset[i] += msetspare[i] * 71;
         }
     }
     debug_out(3, "EdgeGraph", "filtering " << mset << " : " << monoset);
     return filterPartitionStackByFunctionWithCells(ps, SquareBrackToFunction(&mset), monoset);
 }
Пример #2
0
int Theme::populateANYThemes(Fl_Browser *o,std::string checkHERE,bool backone){
	debug_out("int populateANYThemes(Fl_Browser *o,std::string "+checkHERE+",bool backone)");
	if(backone){o->add("..");}
	DIR *dir=NULL;
    std::string itemName;
    struct dirent *ent=NULL;
    if ((dir = opendir (checkHERE.c_str())) != NULL) {
        while ((ent = readdir (dir)) != NULL) {
            itemName=ent->d_name;
			std::string fullpath=ent->d_name;
            itemName=itemName.substr(0,(itemName.length()));
            if (!(itemName.compare(".")==0)&&!(itemName.compare("..")==0)&&!(itemName.compare("old")==0)&&!(itemName.compare("2.3.0")==0)){
				//Don't add our random stuff
				if( (!linuxcommon::has_file_extention_at_end(itemName,".in")) && !linuxcommon::has_file_extention_at_end(itemName,".txt") ){
					pugi::xml_document tmp;
					if(checkHERE.rfind('/')!=checkHERE.length()-1){checkHERE+="/";}
					std::string subber = checkHERE+fullpath;
					fullpath=checkHERE+fullpath+"/"+fullpath;
					debug_out(fullpath);
					if( (tmp.load_file(fullpath.c_str())) || (tmp.load_file( subber.c_str())) ){
						o->add(itemName.c_str());
					}
				}
			}
        }
        if(dir!=NULL){closedir (dir);}
    }
    else {
        perror ("");
        return EXIT_FAILURE;
    }
    return 0;
 }
Пример #3
0
SplitState filterPartitionStackByUnorderedFunction(PartitionStack* ps, F f)
{
    debug_out(3, "filterUnFun", "prestate " << ps->printCurrentPartition());
    int cellCount = ps->cellCount();
    // first of all, we need to try to distinguish as many values of F as possible.

    std::map<typename F::result_type, HashType> full_hash;

    for(int i : range1(cellCount))
    {
        typedef std::map<typename F::result_type, unsigned> map_type;
        map_type count_map;
        for(int x : ps->cellRange(i))
        {
            count_map[f(x)]++;
        }

        for(const auto& m : count_map)
        {
            full_hash[m.first] = hash_combine(full_hash[m.first], i, m.second);
        }
    }

    debug_out(3, "filter", "Hash:" << full_hash);
    debug_out(3, "filter", "Function:" << f);
    SplitState ret = filterPartitionStackByFunction(ps, IndirectFunction(MapToFunction(&full_hash), f));
    debug_out(3, "filterUnFun", "poststate " << ps->printCurrentPartition());
    return ret;
}
Пример #4
0
void JSM_Menu::listMenus(Fl_Browser* list_browser){
	debug_out("void listMenus(Fl_Browser* o)");
	list_browser->clear();
    std::string tempString,convertString,tempString2,convertString2,attributeValue,test1,test2;
    if(newStyle() == -1){
        for (int i = 0; i<=9;i++){
            convertString = convert(i);
            if(!isRootMenu(convertString)){
                debug_out("Adding: "+convertString);
                list_browser->add(convertString.c_str());
            }
        }
    }
    else{
        debug_out("New Style Menu");
        for(char i = '0';i<='z';i++){
            convertString=i;
            if((i < ':')||(i > '`')){
                if(!isRootMenu(convertString)){
                    debug_out("Adding: "+convertString);
                    list_browser->add(convertString.c_str());
                }
            }
        }
    }
    list_browser->redraw();
}
Пример #5
0
    void addSolution(const Permutation& sol)
    {
        permutations.push_back(sol);
        D_ASSERT(sol.size() == orbit_mins.size());
        debug_out(3, "SS", "Old orbit_mins:" << orbit_mins);
        for(int i : range1(sol.size()))
        {
            if(sol[i] != i)
            {
                int val1 = walkToMinimum(i);
                int val2 = walkToMinimum(sol[i]);
                int orbit_min = -1;
                if(comparison(val1, val2))
                    orbit_min = val1;
                else
                    orbit_min = val2;

                update_orbit_mins(orbit_min, val1);
                update_orbit_mins(orbit_min, val2);
                update_orbit_mins(orbit_min, i);
                update_orbit_mins(orbit_min, sol[i]);
            }
        }
        debug_out(1, "SS", "Solution found");
        debug_out(3, "SS", "Sol:" << sol);
        debug_out(3, "SS", "New orbit_mins:" << orbit_mins);
    }
Пример #6
0
// This may throw for invalid domain or level.
std::ostream& debug_out(debug_level::flag level, const std::string& domain)
{
	debug_internal::DebugState::domain_map_t& dm = debug_internal::get_debug_state().get_domain_map();

	debug_internal::DebugState::domain_map_t::iterator level_map = dm.find(domain);
	if (level_map == dm.end()) {  // no such domain
		std::string msg = "debug_out(): Debug state doesn't contain the requested domain: \"" + domain + "\".";

		if (domain != "default") {
			debug_out(debug_level::warn, "default") << msg << "\n";
			debug_out(debug_level::info, "default") << "Auto-creating the missing domain.\n";
			debug_register_domain(domain);
			debug_out(debug_level::warn, "default") << "The message follows:\n";
			return debug_out(level, domain);  // try again
		}

		// this is an internal error
		THROW_FATAL(debug_internal_error(msg.c_str()));
	}

	debug_internal::DebugState::level_map_t::iterator os = level_map->second.find(level);
	if (level_map == dm.end()) {
		std::string msg = std::string("debug_out(): Debug state doesn't contain the requested level ") +
				debug_level::get_name(level) + " in domain: \"" + domain + "\".";

		// this is an internal error
		THROW_FATAL(debug_internal_error(msg.c_str()));
	}

	return *(os->second);
}
Пример #7
0
//Void//////////////////////////////////////////////////////////////////
void JSM_Menu::changeMenuInclude(std::string newInclude, std::string old, std::string MENU){
	debug_out("void changeMenuInclude(std::string "+newInclude+", std::string "+old+", std::string "+MENU+")");
	if((newInclude.compare("")==0)||(old.compare("")==0)||(MENU.compare("")==0)){
		debug_out("User sent in an empty value");
		return;
	}
}
Пример #8
0
SplitState filterPartitionStackByUnorderedListFunction(PartitionStack* ps, F f)
{
    debug_out(3, "filterUnListFun", "prestate " << ps->printCurrentPartition());
    int cellCount = ps->cellCount();
    // first of all, we need to try to distinguish as many values of F as possible.

    std::map<typename F::result_type::value_type, HashType> full_hash;

    for(int i : range1(cellCount))
    {
        typedef std::map<typename F::result_type::value_type, unsigned> map_type;
        map_type count_map;
        for(int val : ps->cellRange(i))
        {
            for(const auto& val2 : f(val))
                count_map[val2]++;
        }

        for(const auto& val : count_map)
        {
            full_hash[val.first] = hash_combine(full_hash[val.first], i, val.second);
        }
    }

    SplitState ret = filterPartitionStackByFunction(ps, IndirectVecCollapseFunction(MapToFunction(&full_hash), f));
    debug_out(3, "filterUnListFun", "poststate " << ps->printCurrentPartition());
    return ret;
}
Пример #9
0
int application_start(void)
{
  mxchipInit();
  Platform_Init();
  UART_Init();
  
#ifdef RFLowPowerMode
  ps_enable();
#endif	
  
#ifdef MCULowPowerMode
  mico_mcu_powersave_config(mxEnable);
#endif	
  
  debug_out("\r\n%s\r\nmxchipWNet library version: %s\r\n", APP_INFO, system_lib_version());
  
  debug_out (menu);
  debug_out ("\nMXCHIP> ");
  
  while(1) {
      Main_Menu();
    if(configSuccess){
      wNetConfig.wifi_mode = Station;
      wNetConfig.dhcpMode = DHCP_Client;
      wNetConfig.wifi_retry_interval = 100;
      StartNetwork(&wNetConfig);
      debug_out("connect to %s.....\r\n", wNetConfig.wifi_ssid);
      configSuccess = 0;
      debug_out ("\nMXCHIP> ");
    }
  }
}
Пример #10
0
VALUE exticonv_local_to_utf8(VALUE local_string)
{
#if RJB_RUBY_VERSION_CODE < 190
    check_kcode();
    if(RTEST(objIconvR2J))
    {
        return rb_funcall(objIconvR2J, rb_intern("iconv"), 1, local_string);
    }
    else
    {
        return local_string;
    }
#else
    VALUE cEncoding, encoding, utf8;
    cEncoding = rb_const_get(rb_cObject, rb_intern("Encoding"));
    encoding = rb_funcall(local_string, rb_intern("encoding"), 0);
    utf8 = rb_const_get(cEncoding, rb_intern("UTF_8"));
    if (encoding != utf8)
    {
        VALUE ret = rb_funcall(local_string, rb_intern("encode"), 2, utf8, encoding);
#if defined(DEBUG)
        debug_out(local_string);
        debug_out(ret);
#endif        
        return ret;
    }
    else
    {
	return local_string;
    }
#endif
}
Пример #11
0
std::string JSM_Menu::getItemIcon(int menu, int item, int sub){
	debug_out("std::string getItemIcon(int menu, int item, int sub)");
	pugi::xml_node noder=getNode(menu, "RootMenu", item);
	pugi::xml_node node=getSubNode(sub,noder);
	std::string ret=getAttribute(node,"icon");
	debug_out("icon="+ret);
	return ret;
}
Пример #12
0
Файл: user.c Проект: dborca/mc
/* Calculates the truth value of one lineful of conditions. Returns
   the point just before the end of line. */
static char *test_line (WEdit *edit_widget, char *p, int *result)
{
    int condition;
    char operator;
    char *debug_start, *debug_end;

    /* Repeat till end of line */
    while (*p && *p != '\n') {
        /* support quote space .mnu */
	while ((*p == ' ' && *(p-1) != '\\' ) || *p == '\t')
	    p++;
	if (!*p || *p == '\n')
	    break;
	operator = *p++;
	if (*p == '?'){
	    debug_flag = 1;
	    p++;
	}
        /* support quote space .mnu */
	while ((*p == ' ' && *(p-1) != '\\' ) || *p == '\t')
	    p++;
	if (!*p || *p == '\n')
	    break;
	condition = 1;	/* True by default */

	debug_start = p;
	p = test_condition (edit_widget, p, &condition);
	debug_end = p;
	/* Add one debug statement */
	debug_out (debug_start, debug_end, condition);

	switch (operator){
	case '+':
	case '=':
	    /* Assignment */
	    *result = condition;
	    break;
	case '&':	/* Logical and */
	    *result &= condition;
	    break;
	case '|':	/* Logical or */
	    *result |= condition;
	    break;
	default:
	    debug_error = 1;
	    break;
	} /* switch */
	/* Add one debug statement */
	debug_out (&operator, NULL, *result);
	
    } /* while (*p != '\n') */
    /* Report debug message */
    debug_out (NULL, NULL, 1);

    if (!*p || *p == '\n')
	p --;
    return p;
}
Пример #13
0
SortEvent filterCellByFunction_noSortData(PartitionStack* ps, int cell, F f)
{
    // Start at the end, because then the cell we pass to
    // split remains the same.

    int cellBegin = ps->cellStartPos(cell);
    int cellEnd = ps->cellEndPos(cell);


    // Cheap pass to check if all cells have the same value
    HashType first_val = f(ps->val(cellBegin));

    bool allequal = true;

    for(int pos = cellBegin + 1; pos < cellEnd && allequal; ++pos)
    {
        if(first_val != (HashType)f(ps->val(pos)))
            allequal = false;
    }

    if(allequal)
    {
        SortEvent se(cellBegin, cellEnd);
        debug_out(3, "filter", "all hashes equal: " + toString(first_val));
        se.addHashStart(f(ps->val(cellBegin)), cellBegin);
        se.finalise();
        return se;
    }

    std::sort(ps->cellStartPtr(cell), ps->cellEndPtr(cell), IndirectSorter(f));
    ps->fixCellInverses(cell);


    int cellsplits = 0;

    SortEvent se(cellBegin, cellEnd);

    for(int pos = cellEnd - 2; pos >= cellBegin; --pos)
    {
        if(f(ps->val(pos)) != f(ps->val(pos+1)))
        {
            se.addHashStart(f(ps->val(pos+1)),pos+1);
            cellsplits++;
            if(ps->split(cell, pos+1).hasFailed())
                abort();
        }
    }

    // Have to have information about the first cell too!
    se.addHashStart(f(ps->val(cellBegin)), cellBegin);

    se.finalise();

    D_ASSERT(cellsplits > 0);
    debug_out(3, "filter",  "Succeeded at: " << cell << ", " << cellsplits << " ( " << (cellEnd - cellBegin) << ", " << cellBegin << ", " << cellEnd << ", " << ps->cellCount() << ")\n");
    return se;
}
Пример #14
0
//String////////////////////////////////////////////////////////////////
std::string JSM_Menu::getLabel(std::string MENU){
	debug_out("std::string getLabel(std::string "+MENU+")");
	if(MENU.compare("")==0){
		debug_out("Sent in something empty");
		return "";
	}
	std::string thisMenu = getMenuAttribute(MENU,"label");
	return thisMenu;
}
Пример #15
0
std::string JSM_Menu::getItemLabel(int menu, int item, int sub){
	debug_out("std::string getItemLabel(int menu, int itemline, int sub)");
	pugi::xml_node noder=getNode(menu, "RootMenu", item);
	if(!noder){return "";}
	pugi::xml_node node=getSubNode(sub,noder);
	if(!node){return "";}
	std::string ret=getAttribute(node,"label");
	debug_out("label="+ret);
	return ret;
}
Пример #16
0
/********************************************************************
  DBASE_CLEAR
    Sletter alle informationer i databaserne

********************************************************************/
void dbase_clear(void)
{
  debug_out(" | |==> Cleaning Nick database...\n");
  while (nicks_count)
    nicks_remove(nicks_num[nicks_count-1]->numeric);
  channels_cleanup();
  chanserv_dbase_cleanup();
  debug_out(" | \\==> Databases successfully removed from memory...\n");

}
Пример #17
0
SplitState filterPartitionStackByFunction(PartitionStack* ps, F f)
{
    debug_out(3, "filterByFunction", "prestate " << ps->printCurrentPartition());
    SplitState ret(false);
    if(ps->getAbstractQueue()->hasSortData())
        ret = filterPartitionStackByFunction_withSortData(ps, f);
    else
        ret = filterPartitionStackByFunction_noSortData(ps, f);
    debug_out(3, "filterByFunction", "poststate " << ps->printCurrentPartition() << ":" << ret);
    return ret;
}
Пример #18
0
void server_dump(dbase_server *root, int level)
{
  int i;
  if ((!root) && (!level)) root = servers;
  if (root)
  {
    for (i = 0; i < level; i++) debug_out("| ");
    debug_out("%s (%s) - %s\n", root->name, root->numeric, root->desc);
    for (i = 0; i < root->children_count; i++)
      server_dump(root->children[i], level+1);
  }
}
Пример #19
0
void InitializeEventHandler_Send( void )
{
	key_t key;
	
	key = ftok( UI_CTRL_PATHNAME, UI_CTRL_PRJ_ID_OWNER_SIP );
	
	if( ( qidEventSip = msgget( key, 0666 | IPC_CREAT ) ) == -1 ) {
		debug_out( "Create Sip event queue fail.\n" );
	}

	debug_out( "qidEventSip: %d (K:%d)\n", qidEventSip, key );
}
Пример #20
0
void Theme::setThemeElementTextwithSub(std::string filename,std::string element,std::string subelement,std::string SUBsubelement){
	debug_out("void setThemeElementTextwithSub(std::string "+filename+",std::string "+element+",std::string "+subelement+",std::string "+SUBsubelement+")");
	if(!load(filename,false)){return;}
	std::string temp=getElementText(element,subelement,SUBsubelement);
	if(temp.compare("")==0){
		errorOUT("Did NOT get Button from "+filename);
		return;
	}
	if(!load())debug_out("LOADING base document FAILED");
	if(!setElementText(element,subelement,SUBsubelement,temp)){errorOUT("FAILED setting "+element+" with "+temp+" in the main DOC");}
	else{saveNoRestart();}
}
Пример #21
0
    SplitState fix_buildingRBase(const vec1<int>& fixed_values, bool useOrbits, bool useBlocks, bool useOrbitals, bool rootCall = false)
    {
        debug_out(3, "scpg", "last depth " << last_depth.get() << " new depth " << fixed_values.size());
        D_ASSERT(fixed_values.size() > last_depth.get());
        last_depth.set(fixed_values.size());

        if(useOrbits)
        {
            doCacheCheck(config.useOrbits, tracking_first_found_orbits,
                         [this](const vec1<int>& v){ return this->fillRBaseOrbitPartitionCache(v); },
                         fixed_values, "orbits");
        }

        if(useBlocks)
        { 
             doCacheCheck(config.useBlocks, tracking_first_found_blocks,
                         [this](const vec1<int>& v){ return this->fillRBaseBlocksCache(v); },
                         fixed_values, "blocks");
        }

        if(useOrbitals)
        { 
            doCacheCheck(config.useOrbitals, tracking_first_found_orbitals,
                         [this](const vec1<int>& v){ return this->fillRBaseOrbitalsCache(v); },
                         fixed_values, "orbitals");
        }

        SplitState ss(true);

        int fixed_size = fixed_values.size();

        if(useOrbits)
        {
            const vec1<int>* part = 0;
            if(tracking_first_found_orbits.get() >= 0)
                part = this->getRBaseOrbitPartition_cached(tracking_first_found_orbits.get());
            else
                part = this->getRBaseOrbitPartition_cached(fixed_size);
            debug_out(3, "scpg", "fix_rBase:orbits");
            if(!part->empty())
                ss = filterPartitionStackByFunction(ps, SquareBrackToFunction(part));
            if(ss.hasFailed())
                return ss;
        }

        if( ( StabChainConfig::doConsiderIfNonTrivial(config.useOrbitals)
            && fixed_size == tracking_first_found_orbitals.get() ) ||
            ( config.useOrbitals == StabChainConfig::always ) ||
            ( rootCall ) )
        { return signal_changed_generic(range1(ps->cellCount()), identityPermutation()); }

        return ss;
    }
Пример #22
0
// Set the date on the MFD
void out_saitek_t::set_date(int year, int month, int day)
{
    if (!a_attached) return;
    int res;
    if (a_product == x52_other_device) return;
    unsigned short datedata = day | (month<<8);
    unsigned short yeardata = year;
    res = send_usb(0xC4,datedata);
    if (res < 0) debug_out(err,"out_saitek: cannot set day to %d and month to %d: %s",day,month,usb_error(res));
    res = send_usb(0xC8,yeardata);
    if (res < 0) debug_out(err,"out_saitek: cannot set year to %d: %s",year,usb_error(res));
}
Пример #23
0
std::string Theme::getButton(std::string element,std::string themefile){
	debug_out("std::string getButton(std::string "+element+")");
	if(!load(themefile,false)){return "";}
	std::string filename=getElementText(element);
	if(linuxcommon::test_file(filename)){
		debug_out(filename+" is a file");
		return filename;
	}
	debug_out(filename+" is NOT a file still going to try to make it happen...");
	if(!load(themefile,false)){return "";}
	std::vector<std::string> icon_paths=IconPaths();
	return linuxcommon::test_file_in_vector_path(filename,icon_paths);
}
Пример #24
0
// Init the library
void out_saitek_t::init(void)
{
    debug_out(debug, "out_saitek: searching for a supported Saitek joystick");
    bool found = search();
    if (found) { // if a joystick was found, attach to it
       a_attached = attach();
       if (a_attached) {
           debug_out(debug, "out_saitek: setting initial brightness and welcome message");
           set_display_brightness(0x7F);
           set_led_brightness(0x7F);
           print(ONLINE_MSG);
       }
    }
}
Пример #25
0
SplitState filterPartitionStackByFunctionWithCells(PartitionStack* ps, F f, const Cells& cells)
{
    debug_out(3, "filterByFunction", "prestate " << ps->printCurrentPartition());
    SplitState ret(false);
    if(ps->getAbstractQueue()->hasSortData())
    {
        // TODO : Use cells
        ret = filterPartitionStackByFunction_withSortData(ps, f);
    }
    else
        ret = filterPartitionStackByFunctionWithCells_noSortData(ps, f, cells);
    debug_out(3, "filterByFunctionWC", "poststate " << ps->printCurrentPartition() << ":" << ret);
    return ret;
}
Пример #26
0
bool validateFixedCell(PartitionStack* ps, int cell, int hash, F f)
{
    debug_out(3, "filter", "validating fixed cell by hash " << hash);
    for(int val : ps->cellRange(cell))
    {
        if((int)f(val) != hash)
        {
            debug_out(3, "filter", "error: found " << f(val) << " for " << val);
            return false;
        }
    }
    RECORD_STATS(addSortStat(Stats::Sort(ps->cellSize(cell), 1, true)));
    return true;
}
Пример #27
0
void CAsyncConnect::startConnect(TSockAddr addr)
{
	debug_out(">>-->>>>> CAsyncConnect::startConnect 00 \n");
	if (inProgress)
	{
		DBG_C("EE: cntr busy");
		debug_out(">>-->>>>> CAsyncConnect::startConnect 01 \n");
		return;
	}

	this->addr = addr;

	connected = false;

	_LIT(KL2Cap, "L2CAP");
	if (error0)
	{
		DBG_C("EE:CAsyncCC error0");
		debug_out(">>-->>>>> CAsyncConnect::startConnect 02 \n");
		return;
	}

	SAFE_CLOSEDEL(sock);
	sock =  new RSocket();

	if (sock->Open(ss, KL2Cap) != KErrNone)
	{
		error0 = true;
		DBG_C("EE: CAsyncCC");
		SAFE_DEL(sock);
		debug_out(">>-->>>>> CAsyncConnect::startConnect 03 \n");
		return;
	}
	addr.SetPort(7);

	CAsyncAccept::disableSecurity((TBTSockAddr*)&addr);

//	char tmp[128];
//	resolve(addr, tmp);
//	//DBG_C("II: !con to [%s]", tmp);

	inProgress = true;
	state = S_CONNECTING;
	sock->Connect(addr, iStatus);
	//DBG_C("II: wait con ...");
	debug_out("sock->Connect: %d", iStatus);
	SetActive();
	//debug_out(">>-->>>>> CAsyncConnect::startConnect 04 \n");
}
Пример #28
0
void stop_middleware_frontend(int sock) {

  if (myname[0] == '\0') {
    debug_out(2, "Not registered!\n");
    exit(1);
  }

  if (!delete_entry(NSDB, myname)) {
    debug_out(2, "Failed to delete data from nameserver\n");
    exit(1);
  }

  myname[0] = '\0';
  close(sock);
}
Пример #29
0
// Set the time on the MFD
void out_saitek_t::set_time(bool h24, int hour, int minute)
{
    if (!a_attached) return;
    unsigned short timedata = minute | (hour<<8) | (h24?0x8000:0);
    int res = send_usb(0xC0,timedata);
    if (res < 0) debug_out(err,"out_saitek: cannot set time to %c:%c: %s",hour,minute,usb_error(res));
}
Пример #30
0
// Set the display brightness
void out_saitek_t::set_display_brightness(char brightness) {
    if (!a_attached) return;
    int res = 0;
    bool mfd = true; // Turn the lights on for the MFD
    res = send_usb(mfd?0xB1:0xB2,brightness);
    if (res < 0) debug_out(err,"out_saitek: error while setting brightness %c on display: %s",brightness,usb_error(res));
}