private void InstanceOnTestConfigurationLoaded(FileInfo fileInfo, byte[] content)
 {
     try
     {
         TestConfiguration15 testConfig = TestConfiguration15.Deserialize(new MemoryStream(content));
         if (testConfig != null)
         {
             foreach (TestConfigurationTestEquipmentItem item in testConfig.TestEquipment)
             {
                 foreach (ItemDescriptionReference itemRef in item.Instrumentation)
                 {
                     var itemDescription   = itemRef.Item as ItemDescription;
                     var documentReference = itemRef.Item as DocumentReference;
                     if (itemDescription != null)
                     {
                         AddInstrument(itemDescription);
                     }
                     else if (documentReference != null)
                     {
                         AddInstrument(documentReference);
                     }
                 }
             }
         }
         lvInstruments.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     }
     catch (Exception e)
     {
         LogManager.Error(e.Message);
     }
 }
Пример #2
0
        private static TestConfiguration15 ProcessAction(TestConfiguration15 obj, AtmlActionType actionType,
                                                         EventArgs args)
        {
            IAtmlController <TestConfiguration15> controller = TestConfigurationController.Instance;

            return(Process(obj, actionType, controller, args));
        }
Пример #3
0
 private void Instance_TestConfigurationLoaded(FileInfo fileInfo, byte[] content)
 {
     try
     {
         TestConfiguration15 testConfig = TestConfiguration15.Deserialize(new MemoryStream(content));
         if (testConfig != null)
         {
             foreach (object element in testConfig.TestProgramElements)
             {
                 var hardwareReference = element as ConfigurationResourceReference;
                 if (hardwareReference != null)
                 {
                     var itemDesc = hardwareReference.Item as ItemDescription;
                     var itemRef  = hardwareReference.Item as DocumentReference;
                     if (itemRef != null)
                     {
                         AddTestAdapter(itemRef);
                     }
                     else if (itemDesc != null)
                     {
                         AddTestAdapter(itemDesc);
                     }
                 }
             }
         }
         lvAdapters.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     }
     catch (Exception e)
     {
         LogManager.Error(e.Message);
     }
 }
 private void ClearControls()
 {
     Clear();
     _testConfiguration = null;
     //if (_refeshTimer != null)
     //    _refeshTimer.Stop();
 }
 public void LoadTestConfiguration(Document document)
 {
     if (document != null)
     {
         testConfigurationControl1.TestConfiguration =
             TestConfiguration15.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
     }
 }
Пример #6
0
        /**
         *
         */

        protected virtual void OnTranslatedInputDocument(TestConfiguration15 testConfiguration)
        {
            TranslatedInputDocumentDelegate handler = InputDocumentTranslated;

            if (handler != null)
            {
                handler(testConfiguration);
            }
        }
Пример #7
0
        protected virtual void OnTestConfigurationSaved(TestConfiguration15 testconfiguration)
        {
            TestConfigurationSaveHandler handler = TestConfigurationSaved;

            if (handler != null)
            {
                handler(testconfiguration);
            }
        }
 private void btnUndo_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes ==
         MessageBox.Show(@"Undo your changes?",
                         @"V E R I F I C A T I O N",
                         MessageBoxButtons.YesNo,
                         MessageBoxIcon.Question))
     {
         if (!string.IsNullOrEmpty(UndoBuffer))
         {
             _testConfiguration = TestConfiguration15.Deserialize(UndoBuffer);
             DataToControls();
             SetControlStates();
         }
     }
 }
Пример #9
0
        public static void CreateProject(ProjectInfo projectInfo)
        {
            //--- Prompt for a test set name ---//
            //--- Check if the name exisists ---//
            //--- If name exists then notify the user, ask if they want to open that test set ---//
            //--- Otherwise create the test set and open it ---//
            if (projectInfo != null)
            {
                TestProgramSet currentTestProgramSet = TestProgramSet.CreateTestSet(projectInfo.ProjectName);
                if (currentTestProgramSet != null)
                {
                    SaveProjectInfo(projectInfo, currentTestProgramSet);
                    OpenProject(projectInfo.ProjectName);
                    Document uutDescriptionDocument = DocumentManager.GetDocument(projectInfo.UutId);
                    if (uutDescriptionDocument != null)
                    {
                        SaveATMLDocument(UutManager.BuildAtmlFileName(projectInfo.UutName),
                                         AtmlFileType.AtmlTypeUut,
                                         uutDescriptionDocument.DocumentContent);
                    }

                    //--- Create a Test Description ---//
                    if (uutDescriptionDocument != null)
                    {
                        var uutDoc = new DocumentReference();
                        uutDoc.ID   = "UUT1";
                        uutDoc.uuid = uutDescriptionDocument.uuid;
                        var uutRef = new ItemDescriptionReference();
                        uutRef.Item = uutDoc;
                        var testConfiguration = new TestConfiguration15();
                        testConfiguration.uuid = Guid.NewGuid().ToString();
                        testConfiguration.TestedUUTs.Add(uutRef);
                        SaveATMLDocument(projectInfo.ProjectName + ATMLContext.ATML_CONFIG_FILENAME_SUFFIX,
                                         AtmlFileType.AtmlTypeTestConfiguration,
                                         Encoding.UTF8.GetBytes(testConfiguration.Serialize()));
                    }
                }
            }
        }
 public void LoadTestConfiguration(FileInfo fi, byte[] content)
 {
     try
     {
         if (content != null && content.Length > 0)
         {
             string text = Encoding.UTF8.GetString(content);
             string byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
             if (text.StartsWith(byteOrderMarkUtf8))
             {
                 text = text.Remove(0, byteOrderMarkUtf8.Length);
             }
             testConfigurationControl1.TestConfiguration =
                 TestConfiguration15.Deserialize(text);
         }
     }
     catch (Exception e)
     {
         LogManager.SourceError(ATMLReader.SOURCE, e,
                                "Failed to parse the Test Configuration File. Please make sure it is in the correct format.");
     }
 }
 private void LoadOutputText(TestConfiguration15 testConfiguration)
 {
     //No need to do this now that we have a file watcher
     //ATMLOutputText = testConfiguration.Serialize();
 }
Пример #12
0
        /**
         *
         */

        public void TranslateInputDocument()
        {
            if (_content != null && IsParsible())
            {
                try
                {
                    //---------------------------------//
                    //--- Setup XML reader settings ---//
                    //---------------------------------//
                    ValidationEventHandler validationHandler = (s, ee) => LogManager.SourceError(SOURCE, ee.Exception);
                    var settings = new XmlReaderSettings();
                    settings.ValidationType          = ValidationType.None;
                    settings.ValidationFlags         = XmlSchemaValidationFlags.None;
                    settings.ValidationEventHandler += validationHandler;

                    string content = Encoding.UTF8.GetString(_content);
                    if (string.IsNullOrWhiteSpace(content))
                    {
                        return;
                    }
                    using (var sr = new StringReader(content))
                    {
                        using (XmlReader xrXml = new XmlTextReader(sr))
                        {
                            var doc = new XPathDocument(xrXml);

                            string xsdName = SchemaManager.GetSchemaName(Encoding.UTF8.GetString(_content));
                            string xslName = xsdName.Replace(".xsd", ".xsl");

                            StringReader xslReader = GetXSLReader(xslName);
                            var          xr        = new XmlTextReader(xslReader);
                            var          xslt      = new XslCompiledTransform();
                            xslt.Load(xr);

                            //--------------------------------------------------------------------------//
                            //--- Create an XsltArgumentList for custom transformation functionality ---//
                            //--------------------------------------------------------------------------//
                            var xslArg   = new XsltArgumentList();
                            var fileName = ProjectManager.ProjectName + ATMLContext.ATML_CONFIG_FILENAME_SUFFIX;
                            xslArg.AddParam("documentName", "", fileName);

                            // Add an object to calculate the new book price.
                            var obj = new ReaderTools();
                            //TODO: Figure out all the functionality required for translation
                            xslArg.AddExtensionObject("urn:utrs.atml-reader-tools", obj);

                            //---------------------------//
                            //--- Transform the file. ---//
                            //---------------------------//
                            using (var w = new StringWriter())
                            {
                                var stringBuilder = new StringBuilder();
                                var xws           = new XmlWriterSettings();
                                xws.OmitXmlDeclaration  = true;
                                xws.Indent              = true;
                                xws.NewLineOnAttributes = false;
                                xws.NamespaceHandling   = NamespaceHandling.OmitDuplicates;
                                using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, xws))
                                {
                                    xslt.Transform(doc, xslArg, xmlWriter);
                                    LogManager.SourceTrace(SOURCE, "ATML translation Completed");
                                    try
                                    {
                                        Console.Write(stringBuilder.ToString());
                                        _testConfiguration = TestConfiguration15.Deserialize(stringBuilder.ToString());
                                    }
                                    catch (Exception e)
                                    {
                                        LogManager.SourceError(SOURCE,
                                                               "An error has occurred attempting to marshall the translated document into an ATML Test Configuration object.",
                                                               e);
                                    }
                                    OnTranslatedInputDocument(_testConfiguration);
                                }
                            }
                        }
                    }
                }
                catch (Exception ee)
                {
                    LogManager.SourceError(SOURCE, ee, "An error has occurred attempting to process the input document.");
                }
            }
        }
Пример #13
0
 private void ReaderInputDocumentTranslated(TestConfiguration15 testConfiguration)
 {
 }
Пример #14
0
 private void _configurationForm_TestConfigurationSaved(TestConfiguration15 testConfiguration)
 {
     OnTestConfigurationSaved(testConfiguration);
 }
 private void testConfigurationControl1_TestConfigurationSaved(TestConfiguration15 testConfiguration)
 {
     OnAtmlObjectAction(testConfiguration, AtmlActionType.Edit, EventArgs.Empty);
     OnTestConfigurationSaved(testConfiguration);
 }
        private void ControlsToData()
        {
            if (_testConfiguration == null)
            {
                _testConfiguration = new TestConfiguration15();
            }
            if (_testConfiguration.ConfigurationManager == null)
            {
                _testConfiguration.ConfigurationManager = new ManufacturerData();
            }
            _testConfiguration.uuid = edtUUID.GetValue <string>();
            _testConfiguration.ConfigurationManager   = manufacturerControl1.ManufacturerData;
            _testConfiguration.classified             = securityClassificationControl.Classified;
            _testConfiguration.securityClassification = securityClassificationControl.SecurityClassification;
            _testConfiguration.TestProgramElements    = new List <object>();
            //TPS Tab

            //-------------------------------//
            //--- Add Resource References ---//
            //-------------------------------//
            if (tpsResourceReferenceListControl.ConfigurationResourceReferences != null)
            {
                _testConfiguration.TestProgramElements.AddRange(tpsResourceReferenceListControl.ConfigurationResourceReferences);
            }

            //-------------------------------//
            //--- Add Software References ---//
            //-------------------------------//
            if (tpsSoftwareReferenceListControl.ConfigurationSoftwareReferences != null)
            {
                _testConfiguration.TestProgramElements.AddRange(tpsSoftwareReferenceListControl.ConfigurationSoftwareReferences);
            }

            //-------------------------------//
            //--- Add Document References ---//
            //-------------------------------//
            if (testProgramDocumentationListControl.TestConfigurationDocumentation != null)
            {
                _testConfiguration.TestProgramElements.AddRange(testProgramDocumentationListControl.TestConfigurationDocumentation);
            }


            //--------------------------------//
            //--- Add Additional Resources ---//
            //--------------------------------//
            _testConfiguration.AdditionalResources =
                tpsAdditionalResourceReferenceListControl.ConfigurationResourceReferences;
            //------------------------------//
            //--- Add Addtional Software ---//
            //------------------------------//
            _testConfiguration.AdditionalSoftware =
                tpsAdditionalSoftwareReferenceListControl.ConfigurationSoftwareReferences;

            //--------------------------//
            //--- Add UUT References ---//
            //--------------------------//
            _testConfiguration.TestedUUTs.Clear();
            foreach (ListViewItem lvi in uutListControl.Items)
            {
                _testConfiguration.TestedUUTs.Add(lvi.Tag as ItemDescriptionReference);
            }

            //-----------------------------------//
            //--- Add Test Station References ---//
            //-----------------------------------//
            _testConfiguration.TestEquipment.Clear();
            _testConfiguration.TestEquipment = testStationReferenceControl.TestEquipment;
            _testConfiguration.AtmlName      = ProjectManager.ProjectName;
            UndoBuffer = _testConfiguration.Serialize();
        }
 public void LoadTestConfiguration(TestConfiguration15 testConfiguration)
 {
     testConfigurationControl1.TestConfiguration = testConfiguration;
 }