void CLocaLogicImpl::GetMessageL(const CBBBtDeviceList* devices,
	const TTime& aAtTime,
	TInt& doSendToIndex, 
	TInt& aMessageCode, TDes& aWithName,
	TDes& aWithTitle, auto_ptr<HBufC8>& aBody) 
{
	CALLSTACKITEM_N(_CL("CLocaLogicImpl"), _CL("GetMessage"));
	TInterpreterAutoLock interpr;

	doSendToIndex=-1;

	TInt count=-1;
	const TBBBtDeviceInfo* dev=0;

	TInt max_seen_priority=-1;

	for (dev=devices->First(); dev; dev=devices->Next()) count++;
	
	python_ptr<PyObject> dict_general(PyDict_New());
	if (! dict_general ) User::Leave(KErrNoMemory);
	AddToPyDict(dict_general, "nodename", iNodeName);
	AddToPyDict(dict_general, "time", aAtTime);
	AddToPyDict(dict_general, "bt_count", count);

	// borrowed
	PyObject* main_module = PyImport_AddModule("__main__");
	if (! main_module ) User::Leave(KErrNoMemory);
	// borrowed
	PyObject* global_dict = PyModule_GetDict(main_module);
	if (! global_dict ) User::Leave(KErrNoMemory);
	// borrowed

	TInt index=0;
	dev=devices->First(); // first is the node itself
	for (dev=devices->Next(); dev; dev=devices->Next()) {
		index++;
		TBuf<15> mac;
		dev->iMAC.IntoStringL(mac);
		AddToPyDict(dict_general, "mac", mac);
		AddToPyDict(dict_general, "majorclass", dev->iMajorClass());
		AddToPyDict(dict_general, "minorclass", dev->iMinorClass());

		TBool found=EFalse;
		python_ptr<PyObject> dict_devstats(PyDict_New());
		{
			TBuf<50> node;
			TDevStats s;
			for(found=iDevStats->FirstStats(*dev, node, s); found; 
					found=iDevStats->NextStats(*dev, node, s)) {
				python_ptr<PyObject> dict_dev(
					DevStatToPyDict(s));
				auto_ptr<HBufC8> node8(HBufC8::NewL(node.Length()+2));
				TPtr8 p=node8->Des();
				iCC->ConvertFromUnicode(p, node);
				node8->Des().ZeroTerminate();
				AddToPyDict(dict_devstats, (char*)node8->Ptr(), dict_dev);
			}
		}
		python_ptr<PyObject> dict_msgstats(0);
		{
			TMessageStats s;
			iMessageStats->GetStatsL(*dev, s);
			dict_msgstats.reset(MessageStatToPyDict(s));
		}
		for (int i=0; i<iFunctions->Count(); i++) {
			TScriptError err=RunScript(main_module,
				global_dict, iFunctions->MdcaPoint(i), max_seen_priority,
				dict_general.get(), dict_devstats.get(), 
				dict_msgstats.get(),
				aMessageCode, aWithName,
				aWithTitle, aBody, iErrorMsgBuf, dev->iMAC()
				);
			if (err>EHighestPriority) {
#if !defined(__WINS__) && !defined(CONTEXTLOCA)
				if (IsInArray(iErrorFunctions, iFunctions->MdcaPoint(i))) {
					PyErr_Clear();
					continue;
				}
#endif
				AddToArrayL(iErrorFunctions, iFunctions->MdcaPoint(i));

				TBuf<50> name;
				TInt state=CCnvCharacterSetConverter::KStateDefault;
				iCC->ConvertToUnicode(name, iFunctions->MdcaPoint(i), state);
				name.SetLength(name.Length()-1);
				if (err==EPythonError) {
					AppendCheckingSpaceL(iErrorMsgBuf, _L(" in script "));
					AppendCheckingSpaceL(iErrorMsgBuf, name);
					ReportPythonError(iErrorMsgBuf);
				} else {
					Reporting().UserErrorLog( iErrorMsgBuf,
						_L(" in script "), name);
				}
			} else if (err==EHighestPriority) {
				doSendToIndex=index;
			}
		}
	}
	/*
	// phone or PDA
	if (aDevice.iMajorClass()==0x02 || (
		aDevice.iMajorClass()==0x01 && 
		aDevice.iMinorClass()>0x03 )) {
	} else {
		return;
	}
	*/

}
Beispiel #2
0
void DotWriter::WriteToDotLanguage()
{
    int pl_index = 0;
    float pl_time = 0;
    bool is_node = false;
    wxArrayInt index_pl_nodes;

    if(mlines == NULL) return;

    graph = wxT("graph [ranksep=\"0.25\", fontname=") + fontname + wxT(", nodesep=\"0.125\"];");

    hnode = wxT("node [label=\"\\N\", fontsize=\"9.00\", fontname=") + fontname + wxT(", style=\"") + style +
            wxT("\", height=0, width=0, shape=") + shape + wxT(", fontcolor=") + cwhite + wxT("];");

    hedge = wxT("edge [fontname=") + fontname + wxT("];");

    // graph []; -- not used

    m_OutputString += begin_graph + wxT("\n") + graph + wxT("\n") + hnode + wxT("\n") + hedge + wxT("\n");

    LineParserList::compatibility_iterator it = mlines->GetFirst();

    while(it) {
        LineParser* line = it->GetData();

        if(line->pline && wxRound(line->time) >= dwtn) {
            is_node = true;
            index_pl_nodes.Add(line->index);
            dlabel = wxString::Format(wxT("%i"), line->index);
            dlabel += wxT(" [label=\"");
            dlabel += OptionsShortNameAndParameters(line->name);
            dlabel += wxT("\\n");
            dlabel += wxString::Format(wxT("%.2f"), line->time);
            dlabel += wxT("% \\n");
            dlabel += wxT("(");
            // self or children if have function childern line
            // if(line->self >= line->childern)
            //	dlabel += wxString::Format(wxT("%.2f"), line->self);
            // else
            dlabel += wxString::Format(wxT("%.2f"), line->self + line->children);
            dlabel += wxT("s)");
            dlabel += wxT("\\n");
            if(line->called0 != -1) dlabel += wxString::Format(wxT("%i"), line->called0) + wxT("x");
            // if(line->recursive)
            //	dlabel += wxT(" (") + wxString::Format(wxT("%i"),line->called0 + line->called1) + wxT("x)");
            dlabel += wxT("\",fontcolor=\"");
            dlabel += DefineColorForLabel(ReturnIndexForColor(line->time, dwcn));
            dlabel += wxT("\", color=\"");
            dlabel += DefineColorForNodeEdge(ReturnIndexForColor(line->time, dwcn));
            //
            dlabel += wxT("\"];"); //, fontsize=\"10.00\"
            //
            m_OutputString += dlabel + wxT("\n");
            //
            dlabel.Clear();
        }
        it = it->GetNext();
    }

    it = mlines->GetFirst();

    float max_time = -2;

    while(it) {
        LineParser* line = it->GetData();

        if(max_time < line->time) max_time = line->time;

        if(line->pline) {
            pl_index = line->index; // index for primary node
            pl_time = line->time;   // time for primary node
        }

        if(line->child && IsInArray(line->nameid, index_pl_nodes) && IsInArray(pl_index, index_pl_nodes) &&
           (wxRound(pl_time) >= dwte)) {
            dedge = wxString::Format(wxT("%i"), pl_index);
            dedge += wxT(" -> ");
            dedge += wxString::Format(wxT("%i"), line->nameid);
            dedge += wxT(" [color=\"");
            dedge += DefineColorForNodeEdge(ReturnIndexForColor(pl_time, dwce)); // color by primary node
            dedge += wxT("\", label=\"");
            // if(line->self != -1)
            // dedge += wxString::Format(wxT("%.2f"),line->self) + wxT("%");
            // dedge += wxT("\\n");
            dedge += wxString::Format(wxT("%i"), line->called0);
            dedge += wxT("x");
            dedge += wxT("\" ,arrowsize=\"0.50\", fontsize=\"9.00\", fontcolor=\"");
            dedge += cblack;
            dedge += wxT("\", penwidth=\"2.00\"];"); // labeldistance=\"4.00\",
            //
            m_OutputString += dedge + wxT("\n");
            //
            dedge.Clear();
        }
        it = it->GetNext();
    }
    m_OutputString += end_graph;

    if(!is_node) { // if the call graph is empty create new graph with label node
        m_OutputString = wxT("digraph e {0 [label=");
        m_OutputString +=
            _(wxString::Format("\"The call-graph is empty; the node threshold ceiling is %d !\"", wxRound(max_time)));
        m_OutputString += wxT(", shape=none, height=2, width=2, fontname=Arial, fontsize=14.00];}");
    }
}