示例#1
0
        //
        // Functions required by the connector
        //

        public async Task <Tuple <AdminShell.AdministrationShell, AdminShell.Asset> > GetAasAssetCore(string index)
        {
            // access
            if (!IsValid())
            {
                throw new PackageConnectorException("PackageConnector connection not valid!");
            }
            if (!index.HasContent())
            {
                throw new PackageConnectorException("PackageConnector::GetAasAssetCore() requires to have " +
                                                    "valid index data!");
            }

            // do the actual query
            var response = await _client.GetAsync(StartQuery("aas", index, "core"));

            response.EnsureSuccessStatusCode();
            var frame = Newtonsoft.Json.Linq.JObject.Parse(await response.Content.ReadAsStringAsync());

            // proudly to the parsing
            AdminShell.AdministrationShell aas = null;
            AdminShell.Asset asset             = null;

            if (frame.ContainsKey("AAS"))
            {
                aas = AdminShellSerializationHelper.DeserializeFromJSON <AdminShell.AdministrationShell>(frame["AAS"]);
            }
            if (frame.ContainsKey("Asset"))
            {
                asset = AdminShellSerializationHelper.DeserializeFromJSON <AdminShell.Asset>(frame["Asset"]);
            }

            // result
            return(new Tuple <AdminShell.AdministrationShell, AdminShell.Asset>(aas, asset));
        }
示例#2
0
 public VisualElementAsset(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.Asset asset)
     : base()
 {
     this.Parent     = parent;
     this.Cache      = cache;
     this.theEnv     = env;
     this.theAsset   = asset;
     this.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#B0B0B0"));
     this.Border     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#404040"));
     this.TagString  = "Asset";
     this.TagBg      = this.Border;
     this.TagFg      = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
示例#3
0
        //
        // Converters & generators
        //

        public void PopulateFakePackage(AdminShellPackageEnv pkg)
        {
            // access
            if (pkg == null)
            {
                return;
            }

            // all files
            int i = 0;

            foreach (var fi in this.FileMap)
            {
                // sure?
                if (fi == null)
                {
                    continue;
                }
                i++;

                // aas
                if (fi.AasIds != null)
                {
                    foreach (var id in fi.AasIds)
                    {
                        var aas = new AdminShell.AdministrationShell(String.Format("AAS{0:00}_{1}", i, fi.Tag));
                        aas.AddDescription("en?", "" + fi.Description);
                        aas.identification = new AdminShell.Identification(
                            AdminShell.Identification.IRI, "" + id);
                        pkg.AasEnv?.AdministrationShells.Add(aas);
                    }
                }

                // asset
                if (fi.AssetIds != null)
                {
                    foreach (var id in fi.AssetIds)
                    {
                        var asset = new AdminShell.Asset(String.Format("Asset{0:00}_{1}", i, fi.Tag));
                        asset.AddDescription("en?", "" + fi.Description);
                        asset.identification = new AdminShell.Identification(
                            AdminShell.Identification.IRI, "" + id);
                        pkg.AasEnv?.Assets.Add(asset);
                    }
                }
            }
        }
        public VisualElementAsset(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env,
            AdminShell.Asset asset)
            : base()
        {
            this.Parent   = parent;
            this.Cache    = cache;
            this.theEnv   = env;
            this.theAsset = asset;

            this.Background = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkAccentColor"];
            this.Border     = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = "Asset";
            RefreshFromMainData();
            RestoreFromCache();
        }
        // Converter

        public AdminShellPackageEnv MakeUpFakePackage()
        {
            // create fake
            var pkg = new AdminShellPackageEnv();

            // all files
            int i = 0;

            foreach (var fi in this.FileMap)
            {
                // sure?
                if (fi == null)
                {
                    continue;
                }
                i++;

                // aas
                var aas = new AdminShell.AdministrationShell(String.Format("AAS{0:00}_{1}", i, fi.Tag));
                aas.AddDescription("en?", "" + fi.Description);
                aas.identification = new AdminShell.Identification(
                    AdminShell.Identification.IRI, "" + fi.AasId);

                // asset
                var asset = new AdminShell.Asset(String.Format("Asset{0:00}_{1}", i, fi.Tag));
                asset.AddDescription("en?", "" + fi.Description);
                asset.identification = new AdminShell.Identification(
                    AdminShell.Identification.IRI, "" + fi.AssetId);
                aas.assetRef = asset.GetAssetReference();

                // add
                pkg.AasEnv?.AdministrationShells.Add(aas);
                pkg.AasEnv?.Assets.Add(asset);
            }

            //ok
            return(pkg);
        }
示例#6
0
文件: Program.cs 项目: i-Asset/basyx
        public static void Test4()
        {
            // MAKE or LOAD prefs
            InputFilePrefs prefs  = new InputFilePrefs();
            var            preffn = "prefs.json";

            try {
                if (File.Exists(preffn))
                {
                    Log.WriteLine(2, "Opening {0} for reading preferences ..", preffn);
                    var init = File.ReadAllText(preffn);
                    Log.WriteLine(2, "Parsing preferences ..");
                    prefs = JsonConvert.DeserializeObject <InputFilePrefs>(init);
                }
                else
                {
                    Log.WriteLine(2, "Using built-in preferences ..");
                    var init = @"{ 'filerecs' : [
                            { 'fn' : 'data\\thumb-usb.jpeg',                'submodel' : 'thumb',   'targetdir' : '/',                      'args' : [ ] },
                            { 'fn' : 'data\\USB_Hexagon.stp',               'submodel' : 'cad',     'targetdir' : '/aasx/cad/',             'args' : [ '0173-1#02-ZBQ121#003' ] },
                            { 'fn' : 'data\\USB_Hexagon.igs',               'submodel' : 'cad',     'targetdir' : '/aasx/cad/',             'args' : [ '0173-1#02-ZBQ128#008' ] },
                            { 'fn' : 'data\\FES_100500.edz',                'submodel' : 'cad',     'targetdir' : '/aasx/cad/',             'args' : [ '0173-1#02-ZBQ133#002' ] },
                            { 'fn' : 'data\\USB_Hexagon_offen.jpeg',        'submodel' : 'docu',    'targetdir' : '/aasx/documentation/',   'args' : [ 'Drawings', '0173-1#02-ZWY722#001', 'Product rendering open', 'V1.2', '0173-1#02-ZHK61a#002' ] },
                            { 'fn' : 'data\\USB_Hexagon_geschlossen.jpeg',  'submodel' : 'docu',    'targetdir' : '/aasx/documentation/',   'args' : [ 'Presales', '0173-1#02-ZWX723#001', 'Product rendering closed', 'V1.2c', '0173-1#02-ZHK622#001' ] },
                            { 'fn' : 'data\\docu_cecc_presales_DE.PDF',     'submodel' : 'docu',    'targetdir' : '/aasx/documentation/',   'args' : [ 'Presales', '0173-1#02-ZWX723#001', 'Steuerungen CECC', 'V2.1.3', '0173-1#02-ZHK622#001' ] },
                            { 'fn' : 'data\\docu_cecc_presales_EN.PDF',     'submodel' : 'docu',    'targetdir' : '/aasx/documentation/',   'args' : [ 'Presales', '0173-1#02-ZWX723#001', 'Controls CECC', 'V2.1.4', '0173-1#02-ZHK622#001' ] },
                            { 'fn' : 'data\\USB_storage_medium_datasheet_EN.pdf', 'submodel' : 'docu', 'targetdir' : '/aasx/documentation/', 'args' : [ 'Technical specification', '0173-1#02-ZWX724#001', 'Datenblatt Steuerung CECC-LK', 'V1.0', '0173-1#02-ZHK622#001' ] },
                            { 'fn' : 'data\\docu_cecc_install_DE.PDF',      'submodel' : 'docu',    'targetdir' : '/aasx/documentation/',   'args' : [ 'Installation', '0173-1#02-ZWX725#001', 'Kurzbeschreibung Steuerung CECC-LK', 'V3.2a', '0173-1#02-ZHK622#001' ] },
                            { 'fn' : 'data\\docu_cecc_install_EN.PDF',      'submodel' : 'docu',    'targetdir' : '/aasx/documentation/',   'args' : [ 'Installation', '0173-1#02-ZWX725#001', 'Brief description control CECC-LK', 'V3.6b', '0173-1#02-ZHK622#001' ] },
                            { 'fn' : 'data\\docu_cecc_fullmanual_DE.PDF',   'submodel' : 'docu',    'targetdir' : '/aasx/documentation/',   'args' : [ 'Manual', '0173-1#02-ZWX727#001', 'Beschreibung Steuerung CECC-LK', '1403a', '0173-1#02-ZHK622#001' ] },
                            { 'fn' : 'data\\docu_cecc_fullmanual_EN.PDF',   'submodel' : 'docu',    'targetdir' : '/aasx/documentation/',   'args' : [ 'Manual', '0173-1#02-ZWX727#001', 'Description Steuerung CECC-LK', '1403a', '0173-1#02-ZHK622#001' ] },
                        ],  'webrecs' : [
                            { 'url' : 'https://www.festo.com/net/de_de/SupportPortal/Downloads/385954/407353/CECC_2013-05a_8031104e2.pdf',          'submodel' : 'docu',      'args' : [ 'Installation', '0173-1#02-ZWX725#001', 'Controlador CECC', '2013-05a', '0173-1#02-ZHK662#002' ] },
                            { 'url' : 'https://www.festo.com/net/SupportPortal/Files/407352/CECC_2013-05a_8031105x2.pdf',                           'submodel' : 'docu',      'args' : [ 'Installation', '0173-1#02-ZWX725#001', 'Controllore CECC', '2013-05a', '0173-1#02-ZHK699#003' ] },
                        ] }";
                    Log.WriteLine(3, "Dump of built-in preferences: {0}", init);
                    Log.WriteLine(2, "Parsing preferences ..");
                    prefs = JsonConvert.DeserializeObject <InputFilePrefs>(init);
                }
            } catch (Exception ex) {
                Console.Error.Write("While parsing preferences: " + ex.Message);
                Environment.Exit(-1);
            }

            // REPOSITORY
            var repo = new AdminShellNS.UriIdentifierRepository();

            try {
                if (!repo.Load("uri-repository.xml"))
                {
                    repo.InitRepository("uri-repository.xml");
                }
            } catch (Exception ex) {
                Console.Error.Write("While accessing URI repository: " + ex.Message);
                Environment.Exit(-1);
            }

            // AAS ENV
            var aasenv1 = new AdminShell.AdministrationShellEnv();

            try
            {
                // ASSET
                var asset1 = new AdminShell.Asset();
                aasenv1.Assets.Add(asset1);
                asset1.SetIdentification("URI", "http://pk.festo.com/3s7plfdrs35", "3s7plfdrs35");
                asset1.AddDescription("EN", "Festo USB Stick");
                asset1.AddDescription("DE", "Festo USB Speichereinheit");

                // CAD
                Log.WriteLine(2, "Creating submodel CAD ..");
                var subCad = CreateSubmodelCad(prefs, repo, aasenv1);

                // DOCU
                Log.WriteLine(2, "Creating submodel DOCU ..");
                var subDocu = CreateSubmodelDocumentation(prefs, repo, aasenv1);

                // DATASHEET
                Log.WriteLine(2, "Creating submodel DATASHEET ..");
                var subDatasheet = CreateSubmodelDatasheet(prefs, repo, aasenv1);
                //var subDatasheet = CreateSubmodelDatasheetSingleItems(repo, aasenv1);

                // VIEW1
                var view1 = CreateStochasticViewOnSubmodels(new AdminShell.Submodel[] { subCad, subDocu, subDatasheet }, "View1");

                // ADMIN SHELL
                Log.WriteLine(2, "Create AAS ..");
                var aas1 = AdminShell.AdministrationShell.CreateNew("URI", repo.CreateOneTimeId(), "1", "0");
                aas1.derivedFrom = new AdminShell.AssetAdministrationShellRef(new AdminShell.Key("AssetAdministrationShell", false, "URI", "www.admin-shell.io/aas/sample-series-aas/1/1"));
                aasenv1.AdministrationShells.Add(aas1);
                aas1.assetRef = asset1.GetReference();

                // Link things together
                Log.WriteLine(2, "Linking entities to AAS ..");
                aas1.submodelRefs.Add(subCad.GetReference() as AdminShell.SubmodelRef);
                aas1.submodelRefs.Add(subDocu.GetReference() as AdminShell.SubmodelRef);
                aas1.submodelRefs.Add(subDatasheet.GetReference() as AdminShell.SubmodelRef);
                aas1.AddView(view1);

                if (true)
                {
                    asset1.assetIdentificationModelRef = new AdminShell.SubmodelRef(subDatasheet.GetReference() as AdminShell.SubmodelRef);
                }
            }
            catch (Exception ex)
            {
                Console.Error.Write("While building AAS: {0} at {1}", ex.Message, ex.StackTrace);
                Environment.Exit(-1);
            }

            if (true)
            {
                try {
                    //
                    // Test serialize
                    // this generates a "sample.xml" is addition to the package below .. for direct usag, e.g.
                    //
                    Log.WriteLine(2, "Test serialize sample.xml ..");
                    using (var s = new StreamWriter("sample.xml"))
                    {
                        var serializer = new XmlSerializer(aasenv1.GetType());
                        var nss        = new XmlSerializerNamespaces();
                        nss.Add("aas", "http://www.admin-shell.io/aas/1/0");
                        nss.Add("IEC61360", "http://www.admin-shell.io/IEC61360/1/0");
                        serializer.Serialize(s, aasenv1, nss);
                    }
                } catch (Exception ex) {
                    Console.Error.Write("While test serializing XML: {0} at {1}", ex.Message, ex.StackTrace);
                    Environment.Exit(-1);
                }
            }

            //
            // Make PACKAGE
            //

            try {
                // use the library function
                var opcfn = "sample-admin-shell.aasx";
                Log.WriteLine(2, "Creating package {0} ..", opcfn);
                var package = new AdminShell.PackageEnv(aasenv1);

                // supplementary files
                Log.WriteLine(2, "Adding supplementary files ..");
                foreach (var fr in prefs.filerecs)
                {
                    Log.WriteLine(2, "  + {0}", fr.fn);
                    package.AddSupplementaryFileToStore(fr.fn, fr.targetdir, Path.GetFileName(fr.fn), fr.submodel == "thumb");
                }

                // save
                Log.WriteLine(2, "Saving ..");
                package.SaveAs(opcfn, writeFreshly: true);
                package.Close();
            } catch (Exception ex) {
                Console.Error.Write("While building OPC package: {0} at {1}", ex.Message, ex.StackTrace);
                Environment.Exit(-1);
            }
        }