public void Load(SignalModel model)
 {
     if (model != null)
     {
         foreach (SignalAttribute signalAttribute in model.Attributes)
         {
             DataGridViewRow row = (DataGridViewRow)dgInterfaces.RowTemplate.Clone();
             row.CreateCells(dgInterfaces, signalAttribute.Name, "");
             dgInterfaces.Rows.Add(row);
         }
     }
 }
Exemplo n.º 2
0
        public SignalModelLibrary(Stream inputStream)
        {
            var xmlDocument = new XmlDocument();
            var sr          = new StreamReader(inputStream);

            _xmlContent = sr.ReadToEnd();
            if (String.IsNullOrEmpty(_xmlContent))
            {
                throw new Exception("Empty Input Document");
            }
            _xmlContent = _xmlContent.Trim();
            xmlDocument.LoadXml(_xmlContent);

            _tsfLibrary = TSFLibrary.Deserialize(_xmlContent);
            foreach (TSFType tsfType in _tsfLibrary.TSF)
            {
                string defaultSchema;
                string modelXml;
                string interfaceSchema = getInterface(xmlDocument, tsfType.name, out defaultSchema, out modelXml);
                if (string.IsNullOrEmpty(defaultSchema))
                {
                    if (xmlDocument.DocumentElement != null && xmlDocument.DocumentElement.Attributes[XMLNS] != null)
                    {
                        defaultSchema = xmlDocument.DocumentElement.Attributes[XMLNS].Value;
                    }
                }
                var model = new SignalModel(
                    tsfType,
                    _tsfLibrary.targetNamespace,
                    defaultSchema,
                    interfaceSchema,
                    modelXml,
                    xmlDocument);

                SetSignalModel(tsfType.name, model);
            }
        }
 private void awbDropListTree_SignalSelected(object sender, XmlDocument tsfDocument)
 {
     var signal = sender as dbSignal;
     _currentSignalModel = sender as SignalModel;
     try
     {
         HourGlass.Start();
         Clear();
         if (!LoadSignalModel( signal ))
         {
             if (!LoadSignalModel( _currentSignalModel ))
             {
                 XmlNode node = SignalManager.Instance.SignalTree.SelectSingleNode( "" );
                 //--- ============================================================ ---//
                 //--- TODO: Determine what to do if the Signal Model does not load ---//
                 //--- ============================================================ ---//
             }
         }
     }
     finally
     {
         HourGlass.Stop();
     }
 }
 private bool LoadSignalModel(SignalModel sm)
 {
     bool loaded = false;
     if (sm != null)
     {
         var modelSignal = sm.TSF.model.Item as Signal;
         var modelStandard = sm.TSF.model.Item as TSFTypeModelStandard;
         if (modelSignal != null)
         {
             Signal signal = modelSignal;
             var items = new List<object>();
             items.AddRange(modelSignal.Items);
             //signalPartsListControl.SignalItems = items;
             signalAttributes.Rows.Clear();
             string uuid = sm.TSF.uuid;
             edtName.Text = modelSignal.name;
             foreach (SignalAttribute attribute in sm.Attributes)
                 signalAttributes.Rows.Add(new object[] { attribute.Name, "" });
         }
         else if (modelStandard != null)
         {
             //--- =========================================================================================== ---//
             //--- TODO: TSFTypeModelStandard is not currently handled - we need to add this is an enhancement ---//
             //--- =========================================================================================== ---//
         }
         loaded = true;
     }
     return loaded;
 }
 private bool LoadSignalModel(dbSignal dbsignal)
 {
     bool loaded = false;
     if (dbsignal != null)
     {
         var dao = new SignalDAO();
         dbsignal = dao.getSignal(dbsignal.signalId);
         _currentSignalModel = SignalManager.GetSignalModel(dbsignal.xmlns, dbsignal.signalName);
         LoadSignalModel(_currentSignalModel);
         loaded = true;
     }
     return loaded;
 }
 private void CreateXmlElementItem(SignalModel model)
 {
     if (model != null)
     {
         var document = new XmlDocument();
         TSFType tsf = model.TSF;
         string xmlns = model.SignalNameSpace;
         string xml = XmlUtils.SerializeObject( model.Signal );
         document.LoadXml( xml );
         XmlElement root = document.DocumentElement;
         if (root != null)
         {
             XmlElement el = root.FirstChild as XmlElement;
             if (el != null && !string.IsNullOrEmpty( edtIn.Text ))
             {
                 XmlAttribute attIn = document.CreateAttribute( "In" );
                 attIn.Value = edtIn.Text;
                 el.Attributes.Append( attIn );
             }
             _signalFunctionType = el;
         }
     }
 }
Exemplo n.º 7
0
 protected virtual void OnSignalSelected( SignalModel model, XmlDocument tsfDocument )
 {
     SelectedSignalModel = model;
     SignalSelectHandler handler = SignalSelected;
     if (handler != null) handler(model, tsfDocument);
 }
Exemplo n.º 8
0
 public void SetSignalModel( string name, SignalModel model )
 {
     _signalModels.Add( name, model );
 }
Exemplo n.º 9
0
        public SignalModelLibrary( Stream inputStream )
        {
            var xmlDocument = new XmlDocument();
            var sr = new StreamReader( inputStream );
            _xmlContent = sr.ReadToEnd();
            if (String.IsNullOrEmpty( _xmlContent ))
                throw new Exception( "Empty Input Document" );
            _xmlContent = _xmlContent.Trim();
            xmlDocument.LoadXml( _xmlContent );

            _tsfLibrary = TSFLibrary.Deserialize( _xmlContent );
            foreach (TSFType tsfType in _tsfLibrary.TSF)
            {
                string defaultSchema;
                string modelXml;
                string interfaceSchema = getInterface( xmlDocument, tsfType.name, out defaultSchema, out modelXml );
                if (string.IsNullOrEmpty( defaultSchema ))
                    if (xmlDocument.DocumentElement != null && xmlDocument.DocumentElement.Attributes[XMLNS] != null)
                        defaultSchema = xmlDocument.DocumentElement.Attributes[XMLNS].Value;
                var model = new SignalModel(
                    tsfType,
                    _tsfLibrary.targetNamespace,
                    defaultSchema,
                    interfaceSchema,
                    modelXml,
                    xmlDocument );

                SetSignalModel( tsfType.name, model );
            }
        }
Exemplo n.º 10
0
 public void SetSignalModel(string name, SignalModel model)
 {
     _signalModels.Add(name, model);
 }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
0
        private void awbDropListTree_SignalSelected(object sender, XmlDocument tsfDocument )
        {
            var signal = sender as dbSignal;
            _currentSignalModel = sender as SignalModel;
            var bscName = sender as string;
            try
            {
                HourGlass.Start();
                Clear();
                if (!string.IsNullOrWhiteSpace( bscName ))
                {

                }
                else if (!LoadSignalModel( signal, tsfDocument ))
                {
                    LoadSignalModel( _currentSignalModel, tsfDocument );
                }
            }
            finally
            {
                HourGlass.Stop();
            }
        }