private void btnValidate_Click(object sender, EventArgs e)
 {
     try
     {
         var error = new StringBuilder(1024 * 1024 * 6);
         TestStationDescription11 testStation = TestStationDescription;
         if (testStation != null)
         {
             if (!SchemaManager.ValidateXml(testStation.Serialize(), ATMLCommon.TestStationNameSpace, error))
             {
                 ATMLErrorForm.ShowValidationMessage(
                     string.Format(
                         "The \"{0}\" Test Station has failed validation against the ATML {1} schema.",
                         testStation.name, ATMLCommon.TestStationNameSpace),
                     error.ToString(),
                     "Note: This error will not prevent you from continuing.");
             }
             else
             {
                 MessageBox.Show(@"This Test Station generated valid ATML");
             }
         }
     }
     catch (Exception err)
     {
         LogManager.Error(err);
     }
 }
Esempio n. 2
0
 public TestStationInstrumentData(TestStationDescription11 testStation,
                                  TestStationDescriptionInstrument testStationInstrument)
 {
     _testStation           = testStation;
     _testStationInstrument = testStationInstrument;
     _instrumentDescription = GetInstrumentDescription(testStationInstrument);
     _itemDescription       = GetItemDescription(testStationInstrument);
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /**
         * Called when the Hardware Description is a Test Station.
         */

        private void ProcessTestStationPath(TestStationDescription11 testStationDescription)
        {
            Capabilities capabilities = testStationDescription.Capabilities;

            ProcessCapabilitites(capabilities);
            if (!CapabilitiesOnly)
            {
                ProcessHardwareItemSwitching(testStationDescription.Switching);
            }
        }
Esempio n. 5
0
        private void AddListItem(TestStationDescription11 testStation, Color bgColor)
        {
            var lv1 = new ListViewItem(testStation.name);

            lv1.Checked = true;
            lv1.SubItems.Add(testStation.uuid);
            lv1.BackColor = bgColor;
            lv1.Tag       = testStation;
            lvTestStations.Items.Add(lv1);
        }
        protected override void OnSaved()
        {
            base.OnSaved();
            TestStationDescription11 testStation = testStationControl2.TestStationDescription;

            if (testStation != null)
            {
                UpdateAtmlViewContent(testStation);
            }
        }
Esempio n. 7
0
 private void SaveTestStation(TestStationDescription11 testStation)
 {
     if (testStation != null)
     {
         string   content  = testStation.Serialize();
         Document document = DocumentManager.GetDocument(testStation.uuid);
         if (document != null)
         {
             document.DocumentContent = Encoding.UTF8.GetBytes(content);
             PersistanceController.Save(document);
         }
     }
 }
 public TestStationForm()
 {
     InitializeComponent();
     InitViewButton(btnViewATML);
     Saved    += delegate { UpdateAtmlViewContent(TestStationDescription); };
     Canceled += delegate
     {
         if (!string.IsNullOrWhiteSpace(originalSerializedATMLObject))
         {
             testStationControl2.TestStationDescription =
                 TestStationDescription11.Deserialize(originalSerializedATMLObject);
         }
     };
 }
Esempio n. 9
0
 public void AddSelectedTestStation(TestStationDescription11 testStation)
 {
     if (!SelectedTestStations.Contains(testStation))
     {
         SelectedTestStations.Add(testStation);
         List <TestStationDescriptionInstrument> instruments = testStation.Instruments;
         if (instruments != null)
         {
             foreach (TestStationDescriptionInstrument testStationDescriptionInstrument in instruments)
             {
                 AddAvailableInstrument(new TestStationInstrumentData(testStation, testStationDescriptionInstrument));
             }
         }
     }
 }
        protected override void ControlsToData()
        {
            if (_hardwareItemDescription == null)
            {
                _hardwareItemDescription = new TestStationDescription11();
            }
            base.ControlsToData();
            var testStation = _hardwareItemDescription as TestStationDescription11;

            if (testStation != null)
            {
                testStation.Instruments = testStationDescriptionInstrumentListControl1.TestStationDescriptionInstruments;
                testStation.uuid        = edtUUID.GetValue <string>();
            }
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        protected override void LoadList()
        {
            Clear();
            _testStationDescriptions.Clear();
            List <Document> instruments =
                DocumentManager.GetDocumentsByType((int)dbDocument.DocumentType.TEST_STATION_DESCRIPTION);

            foreach (Document document in instruments)
            {
                try
                {
                    _testStationDescriptions.Add(
                        TestStationDescription11.Deserialize(
                            Encoding.UTF8.GetString(document.DocumentContent).Replace('\0', ' ').Trim()));
                }
                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();
        }
Esempio n. 13
0
        private static TestStationDescription11 ProcessAction(TestStationDescription11 obj, AtmlActionType actionType, EventArgs args)
        {
            IAtmlController <TestStationDescription11> controller = TestStationController.Instance;

            return(Process(obj, actionType, controller, args));
        }
Esempio n. 14
0
        private static void OnEditTestStation(IDocumentEditor source, Document document, TestStationDescription11 obj,
                                              bool saveDocumentOnCompletion)
        {
            EditDocumentDelegate handler = EditTestStation;

            if (handler != null)
            {
                handler(source, document, obj, saveDocumentOnCompletion);
            }
        }
        public static InstrumentDescription CreateInstrument(string partNumber, string stationType)
        {
            InstrumentDescription description = null;
            DocumentDAO           dao         = DataManager.getDocumentDAO();

            try
            {
                AssetIdentificationBean stationAsset = DocumentManager.FindAsset("Model", stationType);
                if (stationAsset == null)
                {
                    throw new Exception(string.Format("Failed to locate the \"{0}\" Test Station", stationType));
                }

                TestStationDescription11 testStation = TestStationController.Instance.Find(stationAsset.uuid);
                if (testStation == null)
                {
                    throw new Exception(string.Format("Failed to locate the \"{0}\" Test Station", stationType));
                }

                //---------------------------------------------------------------//
                //--- String off any numeric instance count (suffix in #xxxx) ---//
                //---------------------------------------------------------------//
                string fullPartNumber = partNumber.Split('#')[0];

                //--------------------------------//
                //--- Prepend the station name ---//
                //--------------------------------//
                fullPartNumber = stationType + "." + fullPartNumber;

                dao.StartTransaction();
                AssetIdentificationBean asset;
                description = new InstrumentDescription();
                var identificationNumber = new ManufacturerIdentificationNumber();
                identificationNumber.number           = fullPartNumber;
                identificationNumber.manufacturerName = "[Unknown]";
                identificationNumber.type             = IdentificationNumberType.Part;
                description.name                                 = fullPartNumber;
                description.uuid                                 = Guid.NewGuid().ToString();
                description.Identification                       = new ItemDescriptionIdentification();
                description.Identification.ModelName             = partNumber;
                description.Identification.IdentificationNumbers = new List <IdentificationNumber>();
                description.Identification.IdentificationNumbers.Add(identificationNumber);
                //Add document to document database
                //The UUT is a Model Number Asset so we will use a model name for the filename
                //We will also use the ATML Standard number (1671.3) for part of the file name
                string docName = string.Format("{0}.1671.2.xml", FileUtils.MakeGoodFileName(fullPartNumber));

                var document = new Document();
                document.Description     = description.name;
                document.uuid            = description.uuid;
                document.name            = docName;
                document.Item            = description.Serialize();
                document.DocumentContent = Encoding.UTF8.GetBytes(document.Item);
                document.ContentType     = "text/xml";
                document.DocumentType    = dbDocument.DocumentType.INSTRUMENT_DESCRIPTION;
                PersistanceController.Save(document);

                //Add reference id to asset lookup
                asset             = new AssetIdentificationBean();
                asset.uuid        = Guid.Parse(description.uuid);
                asset.assetType   = "Part";
                asset.assetNumber = fullPartNumber;
                asset.DataState   = BASEBean.eDataState.DS_ADD;
                asset.save();

                //Add instrument document to atml directory - use part number as file name + 1671.2
                //TODO: Think about this: ProjectManager.SaveATMLDocument(docName, ProjectManager.AtmlTypeInstrument, document.DocumentContent);

                //----------------------------------------------//
                //--- Add the instrument to the test station ---//
                //----------------------------------------------//
                TestStationController.Instance.AddInstrumentReference(testStation,
                                                                      partNumber,
                                                                      document.uuid);//,
                //document.DocumentContent );
                dao.CommitTransaction();
            }
            catch (Exception e)
            {
                dao.RollbackTransaction();
                throw e;
            }
            finally
            {
                dao.EndTransaction();
            }
            return(description);
        }
Esempio n. 16
0
        /**
         *
         */

        public string InitializeTestStaion(string stationType,
                                           string station,
                                           string changeNo,
                                           string dateEntry,
                                           string fst)
        {
            string refNo     = "";
            bool   usesRF    = false;
            bool   usesCNI   = false;
            bool   usesEO    = false;
            bool   usesHPDTS = false;
            bool   usesSGMA  = false;
            bool   isHybrid  = false;
            bool   isRTCass  = false;
            bool   isECass   = false;

            stationType = stationType.ToUpper();
            station     = station.ToUpper();

            if (string.IsNullOrWhiteSpace(station))
            {
                station = CASS;
            }

            if (string.IsNullOrWhiteSpace(stationType))
            {
                stationType = station;
            }

            usesRF    = stationType.Contains(RF);
            usesCNI   = stationType.Contains(CNI);
            usesEO    = stationType.Contains(EO);
            usesHPDTS = stationType.Contains(HPDTS);
            usesSGMA  = stationType.Contains(SGMA);
            isHybrid  = stationType.Contains(HYBRID);
            isRTCass  = stationType.Contains(RTCASS);
            isECass   = stationType.Contains(ECASS);

            if (!isRTCass && stationType.Contains(CASS))
            {
                station = CASS;
            }
            else if (isRTCass)
            {
                station = RTCASS;
            }
            else if (isECass)
            {
                station = ECASS;
            }
            else if (isHybrid)
            {
                station = HYBRID;
            }

            if (usesRF)
            {
                station = station + "_" + RF;
            }
            if (usesCNI)
            {
                station = station + "_" + CNI;
            }
            if (usesEO)
            {
                station = station + "_" + EO;
            }
            if (usesHPDTS)
            {
                station = station + "_" + HPDTS;
            }
            if (usesSGMA)
            {
                station = station + "_" + SGMA;
            }

            const string assetType    = "Model";
            const string contentType  = "text/xml";
            string       documentType = Enum.GetName(typeof(dbDocument.DocumentType),
                                                     dbDocument.DocumentType.TEST_STATION_DESCRIPTION);

            AssetIdentificationBean asset = DocumentManager.FindAsset(assetType, station);

            if (asset != null)
            {
                refNo = asset.uuid.ToString();
            }
            else
            {
                refNo = DocumentManager.CreateDocumentPlaceHolder
                        (
                    station,                                     //Part Number
                    assetType,                                   //Asset Type
                    contentType,                                 //Content Type
                    documentType,                                //Document Type
                    station + " 1671.6 Test Station Description" //Description
                        );
                var ts = new TestStationDescription11();
                ts.Identification           = new ItemDescriptionIdentification();
                ts.name                     = station;
                ts.uuid                     = refNo;
                ts.Identification.ModelName = station;
                Document document = DocumentManager.GetDocument(refNo);
                document.DocumentContent = Encoding.UTF8.GetBytes(ts.Serialize());
                DocumentManager.SaveDocument(document);
            }

            return(refNo);
        }
Esempio n. 17
0
        /**
         * Lookup the Instrument by the part number and test station in the asset table.
         */

        public static String FindInstrumentReference(string partNumber, string stationId)
        {
            string referenceId = "";

            try
            {
                IAtmlController <TestStationDescription11> controller = AtmlControllerFactory <TestStationDescription11> .Controller;
                TestStationDescription11 testStation = controller.Find(Guid.Parse(stationId));
                if (testStation == null)
                {
                    throw new Exception(string.Format(ErrorLocatingTestStation, stationId));
                }
                string stationType        = testStation.Identification.ModelName;
                string basePartNumber     = partNumber.Split('#')[0];
                string fullPartNumber     = stationType + "." + basePartNumber;
                string combinedPartNumber = stationType + "." + partNumber; //--- has "#xxx"
                string instrumentName     = fullPartNumber + ATMLContext.ATML_INSTRUMENT_FILENAME_SUFFIX;

                //--------------------------------------------------------------------------------------------------------//
                //--- TODO: Need to adjust this process
                //---       Strip the #xxx off
                //---       Prefix it with the station name
                //---       Check if instrument is in database - if not create a placeholder
                //---       Get instrument uuid for reference
                //---       Using the original part number (ie with #xxx) make sure its associated with the test station
                //---       This will provide quantities of an instrument via #xxx
                //--------------------------------------------------------------------------------------------------------//

                //-----------------------------------------//
                //--- Look for an asset in the database ---//
                //-----------------------------------------//
                AssetIdentificationBean asset = DocumentManager.FindAsset(AssetTypePart, combinedPartNumber);
                if (asset != null)
                {
                    //-----------------------------//
                    //--- Grab the reference id ---//
                    //-----------------------------//
                    referenceId = asset.uuid.ToString();
                }
                else
                {
                    //--- Lookup Document by Instrument Id ---//
                    Document document = DocumentManager.GetDocumentByName(instrumentName);
                    if (document == null)
                    {
                        //--- We should only prompt if the base part number is missing ---//
                        referenceId = PromptUserToAddInstrument(basePartNumber, stationType, referenceId);
                    }
                    else
                    {
                        referenceId = document.uuid;
                        CreateAsset(referenceId, combinedPartNumber);
                    }
                }

                //-------------------------------------------------------------------------------------------------------//
                //--- Let see if the test station has a reference to the instrument instance, if no we need to add it ---//
                //-------------------------------------------------------------------------------------------------------//
                if (!AtmlControllerFactory <TestStationDescription11> .Controller.HasInstrumentReference(testStation, partNumber))
                {
                    //InstrumentDescription instrument = InstrumentController.FindInstrument(partNumber);
                    AtmlControllerFactory <TestStationDescription11> .Controller.AddInstrumentReference(testStation as TestStationDescription11, partNumber,
                                                                                                        referenceId);
                }
            }
            catch (Exception e)
            {
                LogManager.SourceError(ATMLReader.SOURCE, ErrorSavingInstrument, partNumber, e.Message);
            }
            return(referenceId);
        }