Inheritance: HardwareItemDescription
 public PortSelectionForm(InstrumentDescription instrument)
 {
     InitializeComponent();
     InitResourcePortList();
     InitPhysicalPortList();
     Resize += new EventHandler(ResourcePortSelectionForm_Resize);
     this.instrument = instrument;
     DataToControls();
     btnOk.Click += new EventHandler(btnOk_Click);
 }
 public ResourcePortSelectionForm(Port sourcePort, InstrumentDescription instrument)
 {
     InitializeComponent();
     lvResourcePorts.Columns.Add("Port Name");
     lvResourcePorts.Columns[0].Width = lvResourcePorts.Width;
     lvResourcePorts.FullRowSelect = true;
     lvResourcePorts.CheckBoxes = true;
     Resize += ResourcePortSelectionForm_Resize;
     this.sourcePort = sourcePort;
     this.instrument = instrument;
     DataToControls();
     btnOk.Click += btnOk_Click;
 }
 private static string GetName( InstrumentDescription instrument )
 {
     string name = instrument.name;
     if (string.IsNullOrEmpty( name ))
     {
         if (instrument.Identification != null && !string.IsNullOrEmpty( instrument.Identification.ModelName ))
         {
             name = instrument.Identification.ModelName;
         }
         else
         {
             name = instrument.uuid;
         }
     }
     return name;
 }
        private object GetDataObject()
        {
            var eventArgs = new DataObjectRequestEventArgs();
            OnDataObjectRequested( eventArgs );
            object data = null;
            if (_instrumentDescription != null)
                data = _instrumentDescription;
            else if (_testStationDescription != null)
                data = _testStationDescription;
            else if (_testAdapterDescription != null)
                data = _testAdapterDescription;

            if (data == null)
            {
                if (eventArgs.ObjectItemDescription is InstrumentDescription)
                    data = _instrumentDescription = eventArgs.ObjectItemDescription as InstrumentDescription;
                else if (eventArgs.ObjectItemDescription is TestAdapterDescription1 )
                    data = _testAdapterDescription = eventArgs.ObjectItemDescription as TestAdapterDescription1;
                else if (eventArgs.ObjectItemDescription is TestStationDescription11 )
                    data = _testStationDescription = eventArgs.ObjectItemDescription as TestStationDescription11;
            }

            return data;
        }
 public static bool LoadFromFile(string fileName, out InstrumentDescription obj)
 {
     Exception exception;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an InstrumentDescription object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output InstrumentDescription 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 InstrumentDescription obj, out Exception exception)
 {
     exception = null;
     obj = default(InstrumentDescription);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string input, out InstrumentDescription obj)
 {
     Exception exception;
     return Deserialize(input, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an InstrumentDescription object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output InstrumentDescription 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 InstrumentDescription obj, out Exception exception)
 {
     exception = null;
     obj = default(InstrumentDescription);
     try
     {
         obj = Deserialize(input);
         return true;
     }
     catch (Exception ex)
     {
         exception = ex;
         return false;
     }
 }
        protected override void ControlsToData()
        {
            if (_hardwareItemDescription == null)
            {
                _hardwareItemDescription = new InstrumentDescription();
                capabilitiesControl1.InstrumentDescription = _hardwareItemDescription as InstrumentDescription;
            }
            if (_hardwareItemDescription != null)
            {
                base.ControlsToData();
                var instrumentDescription = _hardwareItemDescription as InstrumentDescription;
                if (instrumentDescription != null)
                {
                    instrumentDescription.securityClassification = securityClassificationControl.SecurityClassification;
                    instrumentDescription.classified = securityClassificationControl.Classified;
                    instrumentDescription.uuid = edtInstrumentUUID.GetValue<String>();
                    if (cmbInstrumentType.SelectedItem != null)
                        instrumentDescription.type = (InstrumentDescriptionType) cmbInstrumentType.SelectedItem;

                    //----------------------------//
                    //--- Get the capabilities ---//
                    //----------------------------//
                    List<object> capabilityItems = capabilitiesControl1.Capabilities != null ? capabilitiesControl1.Capabilities.Items : null;
                    if (capabilityItems != null && capabilityItems.Count > 0)
                    {
                        if (instrumentDescription.Capabilities == null)
                            instrumentDescription.Capabilities = new Capabilities();
                        instrumentDescription.Capabilities = capabilitiesControl1.Capabilities;
                    }
                    else
                    {
                        instrumentDescription.Capabilities = null;
                    }

                    instrumentDescription.Paths = pathListControl.Paths;

                    //---------------------//
                    //--- Get Resources ---//
                    //---------------------//
                    instrumentDescription.Resources = resourceListControl.Resources;

                    //TODO: Walk through all the capability resource port mappings and rebuild the Capability Mappings

                    //----------------------------//
                    //--- Get Power On Results ---//
                    //----------------------------//
                    instrumentDescription.PowerOnDefaults = powerOnDefaultsListControl.PowerOnDefaults;

                    //--------------------------//
                    //--- Get Specifications ---//
                    //--------------------------//
                    instrumentDescription.Specifications = specificationsControl.Specifications;

                    //---------------------//
                    //--- Get Switching ---//
                    //---------------------//
                    instrumentDescription.Switching = switchingListControl.Switching;

                    //-----------------//
                    //--- Get Buses ---//
                    //-----------------//
                    instrumentDescription.Buses = busListControl.Buses;

                    instrumentDescription.Extension = null;
                }
            }
        }
 private static void OnEditInstrument( IDocumentEditor source, Document document, InstrumentDescription obj,
     bool saveDocumentOnCompletion)
 {
     bool ret = false;
     EditDocumentDelegate handler = EditInstrument;
     if (handler != null) handler( source, document, obj, saveDocumentOnCompletion );
 }
 /**
  * Call this method to save the document data to the database.
  */
 private static void SaveInstrumentDescriptionDocument( InstrumentDescription instrumentDescription,
     Document document,
     BASEBean.eDataState dataState)
 {
     var dbDocument = new dbDocument();
     String xml = instrumentDescription.Serialize();
     document.DocumentContent = dbDocument.documentContent = Encoding.UTF8.GetBytes( xml );
     dbDocument.documentSize = xml.Length;
     document.ContentType = dbDocument.contentType = ATMLContext.CONTEXT_TYPE_XML;
     dbDocument.DataState = dataState;
     if (dataState == BASEBean.eDataState.DS_ADD)
         dbDocument.dateAdded = DateTime.UtcNow;
     else if (dataState == BASEBean.eDataState.DS_EDIT)
         dbDocument.dateUpdated = DateTime.UtcNow;
     document.Description = dbDocument.documentDescription = instrumentDescription.Description;
     dbDocument.documentTypeId = (int) dbDocument.DocumentType.INSTRUMENT_DESCRIPTION;
     document.DocumentType = dbDocument.DocumentType.INSTRUMENT_DESCRIPTION;
     document.version = dbDocument.documentVersion = instrumentDescription.version;
     document.name = dbDocument.documentName = instrumentDescription.Identification.ModelName;
     dbDocument.UUID = Guid.Parse( instrumentDescription.uuid );
     document.uuid = instrumentDescription.uuid;
     dbDocument.save();
 }
 /*
  * Handler for the Add Button click event
  */
 private void lvInstruments_OnAdd()
 {
     var form = new InstrumentForm();
     var instrumentDescription = new InstrumentDescription();
     form.InstrumentDescription = instrumentDescription;
     if (DialogResult.OK == form.ShowDialog())
     {
         instrumentDescription = form.InstrumentDescription;
         var document = new Document();
         SaveInstrumentDescriptionDocument( instrumentDescription, document, BASEBean.eDataState.DS_ADD );
         AddDocumentToInstrumentList( document );
         LoadInstrumentPreview();
     }
 }
Esempio n. 13
0
 public SwitchForm(InstrumentDescription instrument)
 {
     InitializeComponent();
     matrixSwitchControl.Visible = false;
     switchControl.Instrument = instrument;
 }
        public void EditDocumentObject()
        {
            try
            {
                ControlsToData();
                if (_document.DataState == BASEBean.eDataState.DS_ADD && string.IsNullOrWhiteSpace( edtItem.Text ))
                {
                    if (_document.DocumentType == dbDocument.DocumentType.INSTRUMENT_DESCRIPTION)
                    {
                        var instrument = new InstrumentDescription();
                        instrument.name = edtDocumentName.GetValue<string>();
                        instrument.uuid = edtUUID.GetValue<string>();
                        instrument.Description = edtDescription.GetValue<string>();
                        _document.DocumentContent = Encoding.UTF8.GetBytes( instrument.Serialize() );
                    }
                    edtItem.Text = Encoding.UTF8.GetString( _document.DocumentContent );
                    SaveDocument();
                }

                if (DocumentManager.EditDocument( this, _document, edtUUID.GetValue<string>(),
                                                  Encoding.UTF8.GetString( _document.DocumentContent ), false ))
                {
                    edtItem.Text = _document.Item;
                }
            }
            catch (Exception e)
            {
                ATMLErrorForm.ShowError( e );
            }
        }
Esempio n. 15
0
 private void InstrumentForm_UndoChanges( object sender, EventArgs e )
 {
     InstrumentDescription = InstrumentDescription.Deserialize( originalSerializedATMLObject );
 }
        protected override void DataToControls()
        {
            if (_hardwareItemDescription == null)
                _hardwareItemDescription = new InstrumentDescription();

            base.DataToControls();

            pathListControl.HardwareItemDescription = _hardwareItemDescription;

            var instrumentDescription = _hardwareItemDescription as InstrumentDescription;
            if (instrumentDescription != null)
            {
                //------------------------------------------------------------------------------------------------------------------------------------//
                //--- Set the Hardware Item Description on the Capabilities Control so any capability references can be added to the Documentation ---//
                //--- TODO: Think about using an Event to notify the Hardware Item Description                                                     ---//
                //------------------------------------------------------------------------------------------------------------------------------------//
                capabilitiesControl1.InstrumentDescription = instrumentDescription;

                securityClassificationControl.SecurityClassification = instrumentDescription.securityClassification;
                securityClassificationControl.Classified = instrumentDescription.classified;

                edtInstrumentUUID.Value = instrumentDescription.uuid;
                cmbInstrumentType.Text = instrumentDescription.type.ToString();

                //----------------------------------//
                //--- Set Hardaware Descriptions ---//
                //----------------------------------//
                hardwareItemDescriptionControl.HardwareItemDescription = instrumentDescription;

                pathListControl.Paths = instrumentDescription.Paths;

                //------------------//
                //--- Set Busses ---//
                //------------------//
                busListControl.Buses = instrumentDescription.Buses;

                //--------------------------//
                //--- Set Specifications ---//
                //--------------------------//
                specificationsControl.Specifications = instrumentDescription.Specifications;

                //------------------------//
                //--- Set Capabilities ---//
                //------------------------//
                if (instrumentDescription.Capabilities != null)
                {
                    capabilitiesControl1.Capabilities = instrumentDescription.Capabilities;
                    //capabilityListControl.CapabilityItems = _instrumentDescription.Capabilities.Items;
                    //capabilityListControl.InstrumentDescription = _instrumentDescription;
                    //TODO: Walk all the interface ports and set each ones mapped resource
                }

                //---------------------//
                //--- Set Resources ---//
                //---------------------//
                resourceListControl.Resources = instrumentDescription.Resources;

                //------------------------------//
                //--- Set Capability Mapping ---//
                //------------------------------//
                if (instrumentDescription.Capabilities != null &&
                    instrumentDescription.Capabilities.CapabilityMap != null)
                    mappingListControl1.Mappings = instrumentDescription.Capabilities.CapabilityMap.ToList();

                //---------------------//
                //--- Set Switching ---//
                //---------------------//
                switchingListControl.Instrument = instrumentDescription;

                //-----------------------------//
                //--- Set Power On Defaults ---//
                //-----------------------------//
                powerOnDefaultsListControl.PowerOnDefaults = instrumentDescription.PowerOnDefaults;

            }
        }
Esempio n. 17
0
 public TestStationInstrumentData( TestStationDescription11 testStation,
     TestStationDescriptionInstrument testStationInstrument)
 {
     _testStation = testStation;
     _testStationInstrument = testStationInstrument;
     _instrumentDescription = GetInstrumentDescription( testStationInstrument );
     _itemDescription = GetItemDescription( testStationInstrument );
 }
 /**
  * Called when the Hardware Description is an Instrument.
  */
 private void ProcessInstrumentPath( InstrumentDescription instrumentDescription )
 {
     Capabilities capabilities = instrumentDescription.Capabilities;
     ProcessCapabilitites( capabilities );
     if( !CapabilitiesOnly )
         ProcessHardwareItemSwitching( instrumentDescription.Switching );
 }