コード例 #1
0
ファイル: roctree.cpp プロジェクト: jjdmol/LOFAR
void ROCTree::SaveNode(std::ofstream &file, ROCTree::ROCTreeNode &node)
{
	if(node.left != 0)
		SaveNode(file, *node.left);
	file
		<< "\t" << node.falseRatio*100.0L
		<< "\t" << node.trueRatio*100.0L
		<< "\t" << node.parameter
		<< std::endl;
	if(node.right != 0)
		SaveNode(file, *node.right);
}
コード例 #2
0
ファイル: roctree.cpp プロジェクト: jjdmol/LOFAR
void ROCTree::Save(const std::string &rocFilename)
{
	std::ofstream rocFile(rocFilename.c_str());
	if(_tree != 0)
		SaveNode(rocFile, *_tree);
	rocFile.close();
}
コード例 #3
0
ファイル: UrlTree.cpp プロジェクト: dblock/baseclasses
bool CUrlTree::SaveNode(FILE * Stream, CTreeElement<CString> * Element, int Level, bool Verbose, long& Total, int DataRows) const {
    int NodeIndex;
    while (Element) {
        NodeIndex = (int) Element->GetData();
        if (NodeIndex != -1)
            Total++;
        if (!DataRows || (DataRows > NodeIndex)) {	  
            m_Progress.Show(Total, GetSize(), Verbose);
            if (! fprintf(Stream, "%d %d %s%s", 
                NodeIndex, 
                Level, 
                CUrl::Escape(Element->GetElement(), true).GetBuffer(), 
                g_strCrLf)) {
                return false;
            }
        }
        if (Element->GetChild()) {
            if (! SaveNode(Stream, Element->GetChild(), Level+1, Verbose, Total, DataRows)) {
                return false;
            }
        }
        Element = Element->GetNext();
    }
    return true;
}
コード例 #4
0
ファイル: dcf.c プロジェクト: WangRobo/FreeRTOS_CANOpen
/**
**
**
** @param d
** @param nodeId
*/
static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
{
    UNS32 abortCode = 0;
    UNS8 buf[4], match = 0, node;
    UNS32 size=4;
    if(d->dcf_status == DCF_STATUS_READ_CHECK){
        // printf("DCF_STATUS_READ_CHECK \n");
        if(getReadResultNetworkDict (d, nodeId, buf, &size, &abortCode) != SDO_FINISHED)
            goto dcferror;
        /* Check if data received match the DCF */
        if(size == d->dcf_size){
            match = 1;
            while(size--)
                if(buf[size] != d->dcf_data[size])
                    match = 0;
        }
        if(match) {
            if(read_consise_dcf_next_entry(d, nodeId) == 0){
                start_and_seek_node(d, nodeId);
            }
        }
        else { /* Data received does not match : start rewriting all */
            if((init_consise_dcf(d, nodeId) == 0) || (write_consise_dcf_next_entry(d, nodeId) == 0))
                goto dcferror;                
            d->dcf_status = DCF_STATUS_WRITE;
        }
    }
    else if(d->dcf_status == DCF_STATUS_WRITE){
        // printf("DCF_STATUS_WRITE \n");
        if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
            goto dcferror;
        if(write_consise_dcf_next_entry(d, nodeId) == 0){
#ifdef DCF_SAVE_NODE
            SaveNode(d, nodeId);
            d->dcf_status = DCF_STATUS_SAVED;
#else //DCF_SAVE_NODE
           start_and_seek_node(d,nodeId);
#endif //DCF_SAVE_NODE
        }
    }
    else if(d->dcf_status == DCF_STATUS_SAVED){
        // printf("DCF_STATUS_SAVED \n");
        if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
            goto dcferror;
        masterSendNMTstateChange (d, nodeId, NMT_Reset_Node);
        d->dcf_status = DCF_STATUS_INIT;
        d->NMTable[nodeId] = Unknown_state;
    }
    return;
dcferror:
    MSG_ERR(0x1A01, "SDO error in consise DCF", abortCode);
    MSG_WAR(0x2A02, "server node : ", nodeId);
    d->NMTable[nodeId] = Unknown_state;
}
コード例 #5
0
ファイル: UrlTree.cpp プロジェクト: dblock/baseclasses
bool CUrlTree::Save(const CString& FileName, bool Verbose, int DataRows) const {
    FILE * OStream2 = fopen((const char *) FileName.GetBuffer(), "wb+");
    if (OStream2) {
        long Total = 0;
        m_Progress.Init(10, Verbose);
        if (! SaveNode(OStream2, m_Head, 0, Verbose, Total, DataRows)) {
            m_Progress.Error(Verbose);
        } else {
            m_Progress.Finish(Verbose);
        }
        fclose(OStream2);
        return true;
    } else {
        return false;  
    }
}