Пример #1
0
        private InstrumentDescription GetInstrumentDescription(TestStationDescriptionInstrument testStationDescriptionInstrument)
        {
            InstrumentDescription instrument        = null;
            DocumentReference     documentReference = testStationDescriptionInstrument.Item as DocumentReference;

            if (documentReference != null)
            {
                try
                {
                    Document document = DocumentManager.GetDocument(documentReference.uuid);
                    if (document != null)
                    {
                        instrument = InstrumentDescription.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
                    }
                }
                catch (Exception e)
                {
                    LogManager.SourceError(ATMLAllocator.SOURCE,
                                           string.Format(
                                               "Error obtaining the Test Station ({0}) - Instrument Description Document for \"{1}\" - Error: {2}",
                                               _testStation.name, documentReference, e.Message), e);
                }
            }
            return(instrument);
        }
Пример #2
0
        private void ValidateToSchema()
        {
            HourGlass.Start();
            var error = new StringBuilder(1024 * 1024 * 6);
            InstrumentDescription instrument = InstrumentDescription;

            try
            {
                if (!SchemaManager.ValidateXml(instrument.Serialize(), ATMLCommon.InstrumentNameSpace, error))
                {
                    HourGlass.Stop();
                    string name = GetName(instrument);
                    ATMLErrorForm.ShowValidationMessage(
                        string.Format("The \"{0}\" Instrument has failed validation against the {1} ATML schema.", name,
                                      ATMLCommon.InstrumentNameSpace),
                        error.ToString(), "Note: This error will not prevent you from continuing.");
                }
                else
                {
                    HourGlass.Stop();
                    MessageBox.Show(@"This Instrument generated valid ATML");
                }
            }
            catch (Exception)
            {
                HourGlass.Stop();
            }
        }
Пример #3
0
        /**
         * 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();
        }
 private void AddInstrument(TestStationInstrumentData testStationInstrumentData, Color bgColor)
 {
     if (testStationInstrumentData != null)
     {
         TestStationDescriptionInstrument testStationInstrument = testStationInstrumentData.TestStationInstrument;
         InstrumentDescription            instrument            = testStationInstrumentData.InstrumentDescription;
         ItemDescription itemDescription = testStationInstrumentData.ItemDescription;
         string          testStationName = testStationInstrumentData.TestStation.name;
         var             itm             = new ListViewItem(testStationName);
         var             modelName       = "";
         if (instrument != null)
         {
             modelName = instrument.name;
             if (instrument.Identification != null &&
                 instrument.Identification.ModelName != null)
             {
                 modelName = instrument.Identification.ModelName;
             }
         }
         else if (itemDescription != null)
         {
             modelName = itemDescription.name;
             if (itemDescription.Identification != null &&
                 itemDescription.Identification.ModelName != null)
             {
                 modelName = itemDescription.Identification.ModelName;
             }
         }
         itm.SubItems.Add(modelName);
         itm.SubItems.Add(testStationInstrument.ID);
         itm.BackColor = bgColor;
         itm.Tag       = testStationInstrumentData;
         lvInstruments.Items.Add(itm);
     }
 }
Пример #5
0
        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);
            }
        }
Пример #6
0
 public TestStationInstrumentData(TestStationDescription11 testStation,
                                  TestStationDescriptionInstrument testStationInstrument)
 {
     _testStation           = testStation;
     _testStationInstrument = testStationInstrument;
     _instrumentDescription = GetInstrumentDescription(testStationInstrument);
     _itemDescription       = GetItemDescription(testStationInstrument);
 }
Пример #7
0
        public static bool EditDocument(IDocumentEditor source, Document _document, string uuid, string documentContent,
                                        bool saveDocumentOnCompletion)
        {
            bool     documentSaved = false;
            Document document      = GetDocument(uuid);

            if (document != null)
            {
                string content = Encoding.UTF8.GetString(_document.DocumentContent);

                switch (document.DocumentType)
                {
                case dbDocument.DocumentType.INSTRUMENT_DESCRIPTION:
                {
                    InstrumentDescription obj =
                        InstrumentDescription.Deserialize(content);
                    OnEditInstrument(source, document, obj, saveDocumentOnCompletion);
                    break;
                }

                case dbDocument.DocumentType.TEST_ADAPTER_DESCRIPTION:
                {
                    TestAdapterDescription1 obj =
                        TestAdapterDescription1.Deserialize(content);
                    OnEditTestAdapter(source, document, obj, saveDocumentOnCompletion);
                    break;
                }

                case dbDocument.DocumentType.TEST_STATION_DESCRIPTION:
                {
                    TestStationDescription11 obj =
                        TestStationDescription11.Deserialize(content);
                    OnEditTestStation(source, document, obj, saveDocumentOnCompletion);
                    break;
                }

                case dbDocument.DocumentType.UUT_DESCRIPTION:
                {
                    UUTDescription obj =
                        UUTDescription.Deserialize(content);
                    OnEditUut(source, document, obj, saveDocumentOnCompletion);
                    break;
                }

                default:
                {
                    MessageBox.Show(
                        string.Format("There is currently no editor available for document type \"{0}\".",
                                      document.DocumentType));
                    break;
                }
                }
            }

            return(documentSaved);
        }
Пример #8
0
        /**
         * Called when the Hardware Description is an Instrument.
         */

        private void ProcessInstrumentPath(InstrumentDescription instrumentDescription)
        {
            Capabilities capabilities = instrumentDescription.Capabilities;

            ProcessCapabilitites(capabilities);
            if (!CapabilitiesOnly)
            {
                ProcessHardwareItemSwitching(instrumentDescription.Switching);
            }
        }
Пример #9
0
 public PortSelectionForm(InstrumentDescription instrument)
 {
     InitializeComponent();
     InitResourcePortList();
     InitPhysicalPortList();
     Resize         += new EventHandler(ResourcePortSelectionForm_Resize);
     this.instrument = instrument;
     DataToControls();
     btnOk.Click += new EventHandler(btnOk_Click);
 }
Пример #10
0
        protected override void OnSaved()
        {
            base.OnSaved();
            InstrumentDescription instrumentDescription = instrumentControl.InstrumentDescription;

            if (instrumentDescription != null)
            {
                UpdateAtmlViewContent(instrumentDescription);
            }
        }
Пример #11
0
 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;
 }
Пример #12
0
        private static InstrumentDescription ProcessAction(InstrumentDescription obj, AtmlActionType actionType, EventArgs args)
        {
            IAtmlController <InstrumentDescription> controller = InstrumentController.Instance;

            obj.DataState = actionType.Equals(AtmlActionType.Add)
                                ? BASEBean.eDataState.DS_ADD
                                : actionType.Equals(AtmlActionType.Edit)
                                      ? BASEBean.eDataState.DS_EDIT
                                      : actionType.Equals(AtmlActionType.Delete)
                                            ? BASEBean.eDataState.DS_DELETE
                                            : BASEBean.eDataState.DS_NO_CHANGE;
            return(Process(obj, actionType, controller, args));
        }
Пример #13
0
        /*
         * 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();
            }
        }
Пример #14
0
        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);
        }
Пример #15
0
 /*
  * Handler for the Edit Button click event
  */
 private void lvInstruments_OnEdit()
 {
     if (lvInstruments.HasSelected)
     {
         var document = lvInstruments.SelectedObject as Document;
         var form     = new InstrumentForm();
         InstrumentDescription instrumentDescription =
             InstrumentDescription.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
         form.InstrumentDescription = instrumentDescription;
         if (DialogResult.OK == form.ShowDialog())
         {
             instrumentDescription = form.InstrumentDescription;
             SaveInstrumentDescriptionDocument(instrumentDescription, document, BASEBean.eDataState.DS_EDIT);
             UpdateExistingDocumentInList(document, instrumentDescription.uuid);
             LoadInstrumentPreview();
         }
     }
 }
Пример #16
0
        private static string PromptUserToAddInstrument(string basePartNumber, string stationType, string referenceId)
        {
            string prompt =
                string.Format(
                    PromptToCreateInstrument,
                    basePartNumber);

            if (DialogResult.Yes ==
                MessageBox.Show(prompt, @"V E R I F Y", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                InstrumentDescription instrument = InstrumentController.CreateInstrument(basePartNumber,
                                                                                         stationType);
                if (instrument == null)
                {
                    throw new Exception(string.Format(FailedToFindInstrument, basePartNumber));
                }
                referenceId = instrument.uuid;
            }
            return(referenceId);
        }
Пример #17
0
        //protected override void btnOk_Click( object sender, EventArgs e )
        protected void btnOk_Clicka(object sender, EventArgs e)
        {
            ValidateChildren();
            if (!ValidateChildren())
            {
                MessageBox.Show(@"Errors Exist. Please correct them to continue.");
            }
            else
            {
                InstrumentDescription instrumentDescription = instrumentControl.InstrumentDescription;

                if (instrumentDescription == null)
                {
                    return;
                }

                //------------------------------------------------------------------------------------------------//
                //--- Cleanup Objects - if Lists are empty then set list to null - may need to switch to array ---//
                //---                   if extension is not used then set it to null                           ---//
                //------------------------------------------------------------------------------------------------//
                if (instrumentDescription.Extension != null && instrumentDescription.Extension.Any != null &&
                    instrumentDescription.Extension.Any.Count == 0)
                {
                    instrumentDescription.Extension = null;
                }

                try
                {
                    InstrumentController.Instance.Save(instrumentDescription);
                    UpdateAtmlViewContent(instrumentDescription);
                    instrumentControl.Invalidate();
                    Update();
                }
                catch (Exception err)
                {
                    MessageBox.Show(string.Format("An error has occurred saving the Instrument.\n{0}", err.Message));
                }
                //OnSaved(e);
                OnSaved();
            }
        }
        private void btnEditObject_Click(object sender, EventArgs e)
        {
            TestStationDescriptionInstrument tsi =
                testStationDescriptionInstrumentControl1.TestStationDescriptionInstrument;

            if (tsi != null && tsi.Item != null)
            {
                var docRef = tsi.Item as DocumentReference;
                if (docRef != null)
                {
                    Document document = DocumentManager.GetDocument(docRef.uuid);
                    if (document == null)
                    {
                        MessageBox.Show(string.Format("Test Station Instrument \"{0}\" does not exist in the document database.", docRef.uuid));
                    }
                    else
                    {
                        InstrumentDescription instrument =
                            InstrumentDescription.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
                        var form = new InstrumentForm();
                        form.InstrumentDescription = instrument;
                        //form.TopMost = true;
                        Visible      = false;
                        form.Closed += delegate
                        {
                            if (DialogResult.OK == form.DialogResult)
                            {
                                instrument = form.InstrumentDescription;
                                document.DocumentContent = Encoding.UTF8.GetBytes(instrument.Serialize());
                                PersistanceController.Save(document);
                            }
                            Visible = true;
                        };
                        form.Show(this);
                    }
                }
            }
        }
Пример #19
0
        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);
        }
        protected override void LoadList()
        {
            Clear();
            _instrumentDescriptions.Clear();
            List <Document> instruments =
                DocumentManager.GetDocumentsByType((int)dbDocument.DocumentType.INSTRUMENT_DESCRIPTION);

            foreach (Document document in instruments)
            {
                try
                {
                    InstrumentDescription id =
                        InstrumentDescription.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
                    _instrumentDescriptions.Add(id);
                }
                catch (Exception e)
                {
                    string msg = "";
                    try
                    {
                        var d = new XmlDocument();
                        d.LoadXml(Encoding.UTF8.GetString(document.DocumentContent));
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                        if (ex.InnerException != null)
                        {
                            msg += Resources.HTML_BR + ex.InnerException.Message;
                        }
                    }
                    LogManager.Error(Resources.Deserialize_document_error, document.name, msg);
                }
            }
            DataToControls();
        }
Пример #21
0
 public SwitchForm(InstrumentDescription instrument)
 {
     InitializeComponent();
     matrixSwitchControl.Visible = false;
     switchControl.Instrument    = instrument;
 }
Пример #22
0
 private void InstrumentForm_UndoChanges(object sender, EventArgs e)
 {
     InstrumentDescription = InstrumentDescription.Deserialize(originalSerializedATMLObject);
 }
Пример #23
0
        private void btnViewATML_Click(object sender, EventArgs e)
        {
            InstrumentDescription instrumentDescription = instrumentControl.InstrumentDescription;

            ShowAtmlContent(instrumentDescription);
        }
Пример #24
0
        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;
                }
            }
        }
Пример #25
0
        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;
            }
        }
Пример #26
0
        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);
            }
        }
Пример #27
0
        /**
         * Call this method to select and import an instrument description document.
         * If the document already exists in the database the user
         * will be prompted to overwrite the existing document.
         */
        private void ImportInstrumentDocument()
        {
            try
            {
                bool   ok2Save = true;
                String xmlContent;
                //---------------------//
                //--- Open the file ---//
                //---------------------//
                if (FileManager.OpenXmlFile(out xmlContent))
                {
                    var dataState = BASEBean.eDataState.DS_ADD;
                    var document  = new Document();
                    InstrumentDescription instrumentDescription = null;
                    //---------------------------------------------------------------------------------------//
                    //--- Check that its a valid Instrument Description document by trying to Marshall it ---//
                    //---------------------------------------------------------------------------------------//
                    try
                    {
                        instrumentDescription = InstrumentDescription.Deserialize(xmlContent);
                    }
                    catch (Exception err)
                    {
                        throw new Exception(string.Format(Resources.Invalid_Instrument_Description_File___0_,
                                                          err.Message));
                    }

                    //------------------------------------------------------------------------------------------------//
                    //--- Next check to see if the uuid already exists - if so ask if the user wants to replace it ---//
                    //------------------------------------------------------------------------------------------------//
                    String uuid = instrumentDescription.uuid;
                    if (DocumentManager.HasDocument(uuid))
                    {
                        ok2Save = false;
                        if (DialogResult.Yes ==
                            MessageBox.Show(
                                Resources
                                .This_Instrument_already_exists__would_you_like_to_overwrite_the_existing_Instrument_Description_,
                                Resources.Q_U_E_S_T_I_O_N,
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question))
                        {
                            document  = DocumentManager.GetDocument(uuid);
                            dataState = BASEBean.eDataState.DS_EDIT;
                            ok2Save   = true;
                        }
                    }

                    //-------------------------//
                    //--- Save the document ---//
                    //-------------------------//
                    if (ok2Save)
                    {
                        SaveInstrumentDescriptionDocument(instrumentDescription, document, dataState);
                        //-----------------------------------------//
                        //--- If Addin new then add to the list ---//
                        //-----------------------------------------//
                        if (dataState == BASEBean.eDataState.DS_ADD)
                        {
                            AddDocumentToInstrumentList(document);
                        }
                        else
                        {
                            //-------------------------------------------------------------------//
                            //--- otherwise, find the existing doc in the list and replace it ---//
                            //-------------------------------------------------------------------//
                            UpdateExistingDocumentInList(document, uuid);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }