示例#1
0
 public static bool LoadFromFile(string fileName, out Resource obj) {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
示例#2
0
 /// <summary>
 /// Deserializes xml markup from file into an Resource object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output Resource object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out Resource obj, out System.Exception exception) {
     exception = null;
     obj = default(Resource);
     try {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
示例#3
0
 /// <summary>
 /// Deserializes workflow markup into an Resource object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output Resource object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out Resource obj, out System.Exception exception) {
     exception = null;
     obj = default(Resource);
     try {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
示例#4
0
 public static bool Deserialize(string xml, out Resource obj) {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
        public void createAVMCyberModel(Cyber.ModelicaComponent cyberModel, string filename)
        {
            // Initialize new AVM cyber model
            avm.cyber.CyberModel avmCyberModel = new avm.cyber.CyberModel();

            // Set Class
            avmCyberModel.Class = cyberModel.Attributes.Class;

            // Set Name
            _avmComponent.Name = cyberModel.Name;
            avmCyberModel.Name = cyberModel.Name;

            _avmComponent.ID = META2AVM_Util.UtilFuncs.ensureMetaIDAttribute();

            _avmComponent.SchemaVersion = "2.5";
            avmCyberModel.Notes = "";
            avmCyberModel.UsesResource = "cyber.path";

            // Create locator string
            string[] path_parts = filename.Split('\\');
            string[] filename_parts = path_parts[path_parts.Length - 1].Split('.');
            avmCyberModel.Locator = cyberModel.Path.Replace('/', '.');

            avm.Resource res = new avm.Resource();
            res.Path = "Cyber\\" + path_parts[path_parts.Length - 1];
            res.Name = "CyberModel";
            res.ID = "cyber.path";
            
            _avmComponent.ResourceDependency.Add(res);

            avm.Resource res2 = new avm.Resource();
            res2.Path = "Cyber\\" + filename_parts[0] + ".xml";
            res2.Name = "CyberXML";
            res2.ID = "cyberxml.path";

            _avmComponent.ResourceDependency.Add(res2);

            // Set Type
            GMEConsole.Out.WriteLine(cyberModel.GetType().Name);
            if (cyberModel.Impl.MetaBase.Name == "SimulinkWrapper")
            {
               avmCyberModel.Type = avm.cyber.ModelType.Simulink;
            }
            else //(cyberModel.Impl.MetaBase.Name == "SignalFlowWrapper")
            {
               avmCyberModel.Type = avm.cyber.ModelType.SignalFlow;
            }
            //else
            //{
                // Other ModelicaComponent types not handled for now
            //    return;
            //}

            // for every InputSignalInterface in the ModelicaComponent create avm.modelica.Connector.
            // Note: Connector in AVM Cyber Model in a copy of AVM ModelicaModel
            foreach (Cyber.InputSignalInterface cyberInputSignalInterface in cyberModel.Children.InputSignalInterfaceCollection)
            {
                createAVMCyberConnector(avmCyberModel.Connector, cyberInputSignalInterface);
            }

            // for every OutputSignalInterface in the ModelicaComponent create avm.modelica.connector
            foreach (Cyber.OutputSignalInterface cyberOutputSignalInterface in cyberModel.Children.OutputSignalInterfaceCollection)
            {
                createAVMCyberConnector(avmCyberModel.Connector, cyberOutputSignalInterface);
            }

            // for every BusInterface in the ModelicaComponent create avm.modelica.connector
            // FIX: may require fix. Not sure!
            foreach (Cyber.BusInterface cyberBusInterface in cyberModel.Children.BusInterfaceCollection)
            {
                createAVMCyberConnector(avmCyberModel.Connector, cyberBusInterface);
            }

            // for every ParameterRef in the ModelicaComponent create avm.modelica.parameter
            foreach (Cyber.ParameterRef cyberParameterRef in cyberModel.Children.ParameterRefCollection)
            {
                createAVMCyberParameter(avmCyberModel.Parameter, cyberParameterRef);
            }
            
            // Add it to _avmComponent's DomainModel List
            _avmComponent.DomainModel.Add(avmCyberModel);
            // 
        }