示例#1
0
/*----------------------------------------------------------------------
  QueryRemoveCurrentAttribute
  params:
  returns:
  ----------------------------------------------------------------------*/
void AmayaAttributeToolPanel::QueryRemoveCurrentAttribute()
{
  if (!IsMandatory())
    RemoveCurrentAttribute();
  else
    /* this attribut is mandatory, user is not allowed to remove it ! */
    TtaDisplaySimpleMessage (INFO, LIB, TMSG_ATTR_MANDATORY);
}
示例#2
0
bool NetworkPNL::Save(const char *filename, IXmlWriterExtension *externalExtension,
                       const LegacyDslFileInfo *gnet)
{
    MarkCallFunction("Save", true);
    static const char fname[] = "Save";
    pnl::CContextPersistence saver;
    pnl::CXMLWriterStd writer;
    pnl::CGroupObj pnlhGroup;
    bool bWriteNodeProperty = false;

    if(!writer.OpenFile(filename))
    {
        ThrowUsingError("can't open file", fname);
    }
    if(!m_pWNet->Net().SaveNet(&saver, &pnlhGroup))
    {
        ThrowInternalError("Can't save file", fname);
    }
    saver.Put(&pnlhGroup, "WrapperInfo", false);

    pnl::CGroupObj propertyGroup, propertyNodes, propDiagInfo;

    propertyGroup.Put(new pnl::CCover<PropertyRealMap >(&m_NetProperty),
        "NetProperty", true);

    Vector<String> aNodeName = Graph().Names();
    String name;
    int i, j, k;
    std::vector<NodeDiagInfo> diagInfo;
    diagInfo.resize(aNodeName.size());

    for(i = 0; i < aNodeName.size(); ++i)
    {
        switch (GetDiagType(i))
        {
        case 1:
            diagInfo[i].m_diagType = "Target";
            break;
        case 2:
            diagInfo[i].m_diagType = "Observation";
            break;
        case 3:
            diagInfo[i].m_diagType = "Auxiliary";
            break;
        }
        diagInfo[i].m_isMandatory = IsMandatory(i);
        diagInfo[i].m_isRanked = IsRanked(i);
        diagInfo[i].m_isDefault = GetDefaultOutcome(i);
        std::vector<bool> targetStates;
        diagInfo[i].m_isTarget.resize(GetOutcomeCount(i));
        for (k = 0; k < GetOutcomeCount(i); ++k)
        {
            diagInfo[i].m_isTarget[k] = IsFaultOutcome(i,k);
        }
        std::vector<double> costs;
        costs.resize(0);
        GetCost(i, costs);
        diagInfo[i].cost = costs[0];
        name = aNodeName[i];
        propDiagInfo.Put(new pnl::CCover<NodeDiagInfo >(&diagInfo[i]),
            name.c_str(), true);
        j = Graph().INode(aNodeName[i]);
        if(!m_aNodeProperty[j].size())
        {
            continue;
        }
        bWriteNodeProperty = true;
        name = aNodeName[i];
        name << ".property";
        propertyNodes.Put(new pnl::CCover<PropertyRealMap >(&m_aNodeProperty[j]),
            name.c_str(), true);
    }
    if(bWriteNodeProperty)
    {
        propertyGroup.Put(&propertyNodes, "Nodes", false);
    }

    saver.Put(&propertyGroup, "Bridge_PNL_to_GeNIe", false);
    saver.Put(&propDiagInfo, "DiagnosisInfo", false);

    if(!saver.SaveViaWriter(&writer))
    {
	ThrowInternalError("Can't save file", fname);
    }

    XmlWriterPNLH genieWriter(&writer);
    externalExtension->WriteExtension(&genieWriter);
    if(!writer.CloseFile())
    {
	ThrowInternalError("Can't close file", fname);
    }

    return true;
}