Exemplo n.º 1
0
        public SignalControl()
        {
            _signal = new Signal();
            InitializeComponent();

            signalInputList.SignalINs = new List<SignalIN>();
            SetOtherAttributesColumnWidths();
            SetInterfaceAttributesColumnWidths();
            Clear();

            XmlDocument tree = SignalManager.Instance.TSFSignalTree;
            awbDropListTree.TreeModel = tree;
        }
        private static void ProcessExtensionAsSignal(Capability capability, Extension ext)
        {
            if (ext != null)
            {
                List<XmlElement> any = ext.Any;
                if (any.Count > 0)
                {
                    String attIn = null;
                    String attOut = null;
                    String name = null;
                    if (SIGNAL.Equals(any[0].LocalName))
                    {
                        if (any[0].HasAttribute(IN))
                            attIn = any[0].GetAttribute(IN);
                        if (any[0].HasAttribute(OUT))
                            attIn = any[0].GetAttribute(OUT);
                        if (any[0].HasAttribute(NAME))
                            attIn = any[0].GetAttribute(NAME);

                        //Console.WriteLine(any[0].OuterXml.Trim());
                        var signal = new Signal();
                        try
                        {
                            signal = MarshallSignal(any, signal);
                        }
                        catch (Exception ee)
                        {
                            LogManager.Error(ee,
                                "An error has occured atttempting to extract the signal from Capability \"",
                                capability.name,
                                "\"\r\n\r\n",
                                ee.Message);
                        }
                    }
                }
            }
        }
 private static Signal MarshallSignal(List<XmlElement> any, Signal signal)
 {
     signal = Signal.Deserialize(any[0].OuterXml.Trim());
     foreach (object item in signal.Items)
     {
         String sigName = item.GetType().Name;
         if (XMLELEMENT.Equals(sigName))
         {
             //MessageBox.Show(String.Format("A class was not found for signal \"{0}\" for the namespace \"{1}\"",
             //                 ((XmlElement)item).Name, ((XmlElement)item).NamespaceURI));
             //Console.Write(((XmlElement) item).LocalName);
             //Console.Write(TAB);
             //Console.Write(EMPTYCHAR);
             //Console.Write(TAB);
             //Console.WriteLine(((XmlElement) item).Value);
         }
         else
         {
             foreach (PropertyInfo prop in item.GetType().GetProperties())
             {
                 //Console.Write(prop.Name);
                 //Console.Write(TAB);
                 //Console.Write(prop.PropertyType);
                 //Console.Write(TAB);
                 //Console.WriteLine(prop.GetValue(item, null));
             }
         }
     }
     return signal;
 }
        private void DataToControls()
        {
            //------------------------------------------------------------//
            //--- Create a new Capability if we don't already have one ---//
            //------------------------------------------------------------//
            if (_capability == null)
                _capability = new Capability();

            //----------------------------------------//
            //--- Now lets start grabbing the data ---//
            //----------------------------------------//
            edtName.Value = _capability.name;
            edtDescription.Value = _capability.Description;
            interfaceListControl.Interface = _capability.Interface;
            Extension ext = _capability.SignalDescription;

            //------------------------------------------------------------//
            //--- Process the SignalDescription as a Extension element ---//
            //------------------------------------------------------------//
            if (ext != null)
            {
                List<XmlElement> any = ext.Any;
                if (any.Count > 0)
                {
                    //-------------------------------------------------//
                    //--- Make sure we're dealing with a Signal tag ---//
                    //-------------------------------------------------//
                    if ("Signal".Equals(any[0].LocalName))
                    {
                        _signal = new Signal();
                        _signal = Signal.Deserialize(any[0].OuterXml.Trim());
                        signalControl.Signal = _signal;

                        //-------------------------------------//
                        //--- Time to walk the Signal Items ---//
                        //-------------------------------------//
                        foreach (object item in _signal.Items)
                        {
                            String sigName = item.GetType().Name;
                            foreach (PropertyInfo prop in item.GetType().GetProperties())
                            {
                                try
                                {
                                    //Console.Write(prop.Name);
                                    //Console.Write("\t");
                                    //Console.Write(prop.PropertyType);
                                    //Console.Write("\t");
                                    //Console.WriteLine(prop.GetValue(item, null));
                                }
                                catch (Exception eee)
                                {
                                }
                            }
                        }
                    }
                }
            }
        }
 private void ControlsToData()
 {
     if (_capability == null)
         _capability = new Capability();
     _capability.name = edtName.GetValue<string>();
     _capability.Description = edtDescription.GetValue<string>();
     _capability.Interface = interfaceListControl.Interface;
     _signal = signalControl.Signal;
     SignalFunctionType sft = signalControl.SignalFunctionType;
     try
     {
         XmlElement elm = XmlUtils.Object2XmlElement(_signal);
         if (elm != null)
         {
             if (_capability.SignalDescription == null)
                 _capability.SignalDescription = new Extension();
             if (_capability.SignalDescription.Any == null)
                 _capability.SignalDescription.Any = new List<XmlElement>();
             _capability.SignalDescription.Any.Clear();
             _capability.SignalDescription.Any.Add(elm);
         }
     }
     catch (Exception e)
     {
         LogManager.Error(e);
     }
 }
Exemplo n.º 6
0
        public SignalModel( TSFType tsf, 
            string nameSpace,
            string defaultNameSpace,
            string interfaceSchema,
            string modelXml,
            XmlDocument xml)
        {
            _tsf = tsf;
            _interfaceSchema = interfaceSchema;
            _name = tsf.name;
            Process( xml );

            _signalNameSpace = nameSpace;
            if (string.IsNullOrEmpty( _baseSignalNameSpace ))
                _baseSignalNameSpace = defaultNameSpace;

            _signal = Signal.Deserialize( modelXml );

            //SaveSignalModel();
        }
Exemplo n.º 7
0
 private void ControlsToData()
 {
     _signal = signalControl.Signal;
 }
Exemplo n.º 8
0
 public SignalForm()
 {
     InitializeComponent();
     Signal = new Signal();
 }
Exemplo n.º 9
0
 public static bool LoadFromFile(string fileName, out Signal obj)
 {
     System.Exception exception;
     return LoadFromFile(fileName, out obj, out exception);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Deserializes xml markup from file into an Signal object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output Signal object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out Signal obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Signal);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Exemplo n.º 11
0
 public static bool Deserialize(string input, out Signal obj)
 {
     System.Exception exception;
     return Deserialize(input, out obj, out exception);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Deserializes workflow markup into an Signal object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output Signal object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string input, out Signal obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Signal);
     try
     {
         obj = Deserialize(input);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Exemplo n.º 13
0
        private bool LoadSignalModel(SignalModel sm, XmlDocument tsfDocument )
        {
            bool loaded = false;
            if (sm != null)
            {
                string tsfNameSpace = sm.SignalNameSpace;
                string tsfName = sm.TSF.name;
                string tsfUuid = sm.TSF.uuid;
                _currentSignalModel = sm;

                Signal modelSignal = new Signal();
                modelSignal.name = tsfName;
                XmlElement el = tsfDocument.CreateElement("tsf", tsfName, tsfNameSpace);
                foreach (SignalAttribute attr in sm.Attributes)
                    el.Attributes.Append( tsfDocument.CreateAttribute( attr.Name ) );

                modelSignal.Items = new[] { el };

                Signal = modelSignal;
                var items = new List<object>();
                items.AddRange(modelSignal.Items);
                signalPartsListControl.SignalItems = items;

                /*
                var modelSignal = sm.TSF.model.Item as Signal;
                var modelStandard = sm.TSF.model.Item as TSFTypeModelStandard;
                if (modelSignal != null)
                {
                    modelSignal.type = tsfName;
                    var la = new List<XmlAttribute>( modelSignal.AnyAttr );
                    if (tsfDocument != null)
                    {
                        XmlAttribute xAttribute1 = tsfDocument.CreateAttribute("tsf-xmlns");
                        XmlAttribute xAttribute2 = tsfDocument.CreateAttribute("tsf-uuid");
                        XmlAttribute xAttribute3 = tsfDocument.CreateAttribute("tsf-name");
                        xAttribute1.Value = tsfNameSpace;
                        xAttribute2.Value = tsfUuid;
                        xAttribute3.Value = tsfName;
                        la.Add(xAttribute1);
                        la.Add(xAttribute2);
                        la.Add(xAttribute3);
                    }
                    modelSignal.AnyAttr = la.ToArray();
                    Signal = modelSignal;
                    var items = new List<object>();
                    items.AddRange(modelSignal.Items);
                    signalPartsListControl.SignalItems = items;
                    signalInterfaceListControl.Load( sm );
                    //dg.Rows.Clear();
                    //string uuid = sm.TSF.uuid;
                    //foreach (SignalAttribute attribute in sm.Attributes)
                    //    dgInterfaceAttributes.Rows.Add(new object[] { attribute.Name, "" });
                }
                else if (modelStandard != null) //TODO: Figure out TSFTypeModelStandard
                {
                }
                 * */
                loaded = true;
            }
            return loaded;
        }