Get parameter of a specific Simulink Block and compare it, Matlab - matlab

I'm parsing a text file with matlab which looks like this :
[Date]
2019-03-27 10:45:10.167618
[Component]
Component_Name : Manager principal
Component_ID : _ocl_MEu9Eemg_bhrv2HEbw
{Port}
Port_Name : FOP 1
Port_ID : _sZMXoEu9Eemg_bhrv2HEbw
Port_Type : Outgoing Port
[Component]
Component_Name : Manager 2
Component_ID : _r-HlMEu9Eemg_bhrv2HEbw
{Port}
Port_Name : FIP 1
Port_ID : _sZWIoku9Eemg_bhrv2HEbw
Port_Type : Incoming Port
[Link]
Link_Name : On/Off
Link_ID : _sZfSkku9Eemg_bhrv2HEbw
Link_Source_Name : Manager principal
Link_Source_ID : _ocl_MEu9Eemg_bhrv2HEbw
Link_Source_Port_Name : FOP 1
Link_Source_Port_ID : _sZMXoEu9Eemg_bhrv2HEbw
Link_Target_Name : Manager 2
Link_Target_ID : _r-HlMEu9Eemg_bhrv2HEbw
Link_Target_Port_Name : FIP 1
Link_Target_Port_ID : _sZWIoku9Eemg_bhrv2HEbw
I create a systeme for each [Component] i find and in each systems i create an input or output if the [Component] is a Source or a Target of a [Link].
In my text file example : On/Off is a link between 'Manager principal' and 'Manager 2'. So in the first System (Manager principal) i have an output called On/Off with a specific tag in tag description i set and in the second system (Manager 2) an input called On/Off with a specific tag in the Block tag i set.
So when i launch my code i have 2 system with 1 block in each system.
In this 2 blocks, if it's about the same link (in this example it is) we have this tag :
#_sZMXoEu9Eemg_bhrv2HEbw ==> #_sZWIoku9Eemg_bhrv2HEbw
The ID of the source port ==> the ID of the target port
This is what distinguish a Link than an other.
The context is : if the user change only the name of the Link for example Off/On instead of On/Off it must not create a new block because it's the same Link. So i would like to make a findBlocks() and for each blocks in the current system, i would like to do : if both ID's in tag description are same than in the text file so we just update the name of the block for example .
Here is the code where i create my blocks :
Update : I success to recover C which is the string inside Block tag.
B = find_system(sprintf('%s', component_NameValue));
C = get_param(find_system(sprintf('%s/%s', component_NameValue, link_NameValue)), 'Tag');
if (compareOut == 1) && (compareSource == 1) % Si c'est un port sortant et que c'est le port source du link
add_block('simulink/Ports & Subsystems/In1',[component_NameValue '/' link_NameValue]); % alors on ajoute un block Output de même nom que le link dans le système du composant que l'on parse
linkDescription = sprintf('Link : \n\n%s ==> %s \n\nComposant : \n\nDe : %s (%s) \nVers : %s (%s) \n\nPort Source : \n\n%s \n%s \n\n', link_NameValue , link_IDValue , link_SourceNameValue , link_SourceIDValue, link_TargetNameValue , link_TargetIDValue, link_SourcePortNameValue, link_SourcePortIDValue);
linkTag = sprintf('#%s ==> #%s', link_SourcePortIDValue, link_TargetPortIDValue);
set_param(gcb, 'Tag', linkTag);
set_param(gcb,'Description',linkDescription); % On ajoute une description au block contenant les infos du lien en question contenus dans le fichier texte
end
if (compareIn == 1) && (compareTarget == 1) % Si c'est un port entrant et que c'est le port target du link
add_block('simulink/Ports & Subsystems/Out1',[component_NameValue '/' link_NameValue]); % alors on ajoute un block Input de même nom que le link dans le système du composant que l'on parse
linkDescription = sprintf('Link : \n\n%s ==> %s \n\nComposant : \n\nDe : %s (%s) \nVers : %s (%s) \n\nPort Target : \n\n%s \n#%s', link_NameValue , link_IDValue , link_SourceNameValue , link_SourceIDValue, link_TargetNameValue , link_TargetIDValue,link_TargetPortNameValue, link_TargetPortIDValue);
linkTag = sprintf('#%s ==> #%s', link_SourcePortIDValue, link_TargetPortIDValue); %On ajoute un # devant l'ID du port pour pouvoir le retrouver et voir si un port à été modifié/rajouté/supprimé
set_param(gcb, 'Tag', linkTag);
set_param(gcb,'Description',linkDescription); % On ajoute une description au block contenant les infos du lien en question contenus dans le fichier texte
end
Thanks for helping in advance

Related

The command Get-InstalledApps doesn't work (Powershell)

I'm trying to list all the apps and programs installed on my computer. The comand Get-InstalledApps it's supossed to work but I get this response:
Get-InstalledApps : El término 'Get-InstalledApps' no se reconoce como nombre de
un cmdlet, función, archivo de script o programa ejecutable. Compruebe si
escribió correctamente el nombre o, si incluyó una ruta de acceso, compruebe que
dicha ruta es correcta e inténtelo de nuevo.
En línea: 1 Carácter: 1
+ Get-InstalledApps
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-InstalledApps:String) [], Com
mandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have already tried to google it, but i'm not capable of solving it.

Select-String after line break

I want to extract the ID from this command:
manage-bde -protectors c: -get
The result of this command is:
Volume C: [Windows]
Tous les protecteurs de clés
Mot de passe numérique :
ID : {XXXXXXX-A315-42C6-9754-XXXXXXXXXX}
Mot de passe :
XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX
TPM :
ID : {XXXXXX-99B3-481B-B3FA-XXXXXXXXXXX}
Profil de validation PCR :
7, 11
(Utilise le démarrage sécurisé pour la validation d’intégrité.)
I want only the ID from the "Mot de passe numérique" (first one, but on some PC, it's the second one) and not the "TPM"
I tried to do that with select-string, but it return both :/
Is there a way to "tell" to select-string to print only the ID after the "mot de passe numérique" expression ?
Thx :)
Use Select-String's -Context parameter to indicate that you're interested in the lines surrounding a match:
$mbdeOutput = manage-bde -protectors c: -get
$mbdeOutput |Select-String 'Mot de passe numérique :' -Context 0,1 |ForEach-Object { $_.Context.PostContext[0] }
This should output the line immediately following Mot de passe numérique :

How to create a template file for org-capture in Spacemacs?

I use a template file to capture a list of books. However last night, after wipe my old installation of spacemacs, when i try to capture a new book, it was impossible. I saw in capture buffer "Invalide Capture Template"
My org-capture-templates configuration is:
(setq org-capture-templates
'(("r" ; touche pour rentrer une référence
"Réference livre" ; on indique que l'on rentre la référence du livre
entry (file+datetree+prompt "~/git/org/Liste_Livres.org") ; On sauve la référence dans le fichier associé.
file "~/git/org/tpl-Liste-Livres.org" ) ; on utilise le template associé au fichier
("l" ; touche pour ajouter une entrée du lycée
"Journal Lycée" ; on indique que l'on rentre la référence du livre
entry (file+datetree "~/git/org/Journal_Lycee.org" ) ; On sauve l'entrée du journal dans le fichier associé.
"* %? %^g") ; on utilise le template pour la note à ajouter
("n" ; touche pour ajouter une note
"Notes" ; on indique que l'on rentre la référence du livre
entry (file "~/git/org/Notes.org" ) ; On sauve la note dans le fichier associé.
"* %? %t %^g \n :PROPERTIES:\n :LIEN: %i %a \n :END:") ; on utilise le template pour la note à ajouter
)
)
My tpl-Liste-Livres.org is:
* Titre :tags:
:PROPERTIES:
:Titre:
:Auteur:
:Pages:
:Editeur:
:Type:
:Sujet:
:Résumé:
:Prets:
:Lien:
:Lu:
:Acheté:
:ISBN:
:END:
I use emacs 25.1.1 from debian stable and spacemacs 0.300 develop
It looks like your targets are out of date with the newest version of org-mode. file+datetree is deprecated, and has been replaced with file+olp+datetree with some new properties to control the datetree type and prompt options. Current templates are documented here
(Note also that your reference book target file+datetree+prompt is also out of date, and would need to be replaced with the file+olp+datetree target, and the new :time-prompt property.)

Query an array of Objects matching word in a string field

After executing a query on a huge ontology using Jena, I exported the results in JSON format in a MongoDB collection named items in a database named galileo.
Now I want to query on the collection to find items by their names (names are in the title field), in particular I want that searching for "Astrolabio", I can retrieve all the objects that contain the word "Astrolabio" in the title field (e.g. "Astrolabio", "Astrolabio Piano" etc...).The objects that interest me are contained in the #graph array.
I tried
db.items.find({"#graph":{$elemMatch:{"title":{$regex: /Astrolabio$/}}}})
but it returns lots of objects that don't contain the searched word too.
I tried also
db.items.find({},{"#graph":{$elemMatch:{"title":{$regex: /Astrolabio$/}}}})
but, as I discovered only after my try, it returns only the first object that match the request.
So what's the correct query for what I'm trying to do?
In order to provide an help, here there is a little slice of the document
{
"_id" : ObjectId("59e07632b5d295462b330c4c"),
"#graph" : [
{
"#id" : "http://minerva.atcult.it/rdf/000000016001",
"#type" : [
"bibo:Book",
"bibo:MultiVolumeBook"
],
"P1053" : [
"1 astrolabe",
"1 astrolabio"
],
"abstract" : [
"This astrolabe presently comprises two tympanums, for latitudes 30° and 33°, the other for latitudes 36° and 42° (corresponding to the regions between Persia and the Black Sea). There is an alidade, a rule, and a rete. The back carries a double shadow square and the zodiacal calendar. The instrument comes with a tooled black leather case (cover missing) containing a sixteenth-century manuscript note stating that the astrolabe was brought from Spain and dates from 1252. The astronomical data inscribed on the astrolabe suggest it may have been built before 1000. According to tradition, the instrument dates from the period of Charlemagne (9th C. ). A very similar Arab astrolabe is documented in a drawing by Antonio da Sangallo il Giovane [the Younger] (c.  1520?) at the Gabinetto dei Disegni e delle Stampe (Department of Drawings and Prints) of the Uffizi. Provenance: Medici collections",
"Questo astrolabio contiene attualmente due timpani, uno per le latitudini 30° e 33°, e l'altro 36° e 42° (corrispondenti alle regioni comprese tra la Persia e il Mar Nero). È completo di alidada, di regolo e di rete. Nel dorso presenta un doppio quadrato delle ombre e il calendario zodiacale. Lo strumento, proveniente dalle collezioni medicee, è completo di custodia di pelle nera lavorata (coperchio mancante) che porta all'interno una nota manoscritta del XVI secolo nella quale si ricorda che l'astrolabio fu portato dalla Spagna e che risale al 1252. I dati astronomici riportati sullo strumento suggeriscono di anticiparne la costruzione a prima del 1000. Secondo la tradizione si tratterebbe di uno strumento del tempo di Carlo Magno (IX secolo). Un astrolabio arabo molto simile a questo è documentato in un disegno di Antonio da Sangallo il Giovane (c. 1520?) conservato presso il Gabinetto dei Disegni e delle Stampe degli Uffizi. Proviene dalle collezioni medicee"
],
"contributor" : "http://minerva.atcult.it/rdf/ed494c3a-2ba6-3464-b34a-a57e4f70c5e0",
"creator" : [
"http://minerva.atcult.it/rdf/d481cbac-209b-3741-bba4-906590d805b3",
"http://minerva.atcult.it/rdf/36e6efa2-6c8f-350e-ae37-479dade48850",
"http://minerva.atcult.it/rdf/47734211-2637-3895-a690-4f33412931ec"
],
"identifier" : "000000016001",
"issued" : "sec. X",
"publisher" : "http://minerva.atcult.it/rdf/90310a84-1133-3356-bb3b-647ae1a7d14d",
"title" : "Astrolabio piano",
"numPages" : [
"1 astrolabio",
"1 astrolabe"
],
"placeOfPublication" : "Fattura araba",
"label" : "Astrolabio piano"
},
{
"#id" : "http://minerva.atcult.it/rdf/000000016002",
"#type" : [
"bibo:MultiVolumeBook",
"bibo:Book"
],
"P1053" : [
"1 astrolabe",
"1 astrolabio"
],
"abstract" : [
"Questo piccolo astrolabio contiene quattro timpani per le latitudini 24° e 30°, 31° e 35°, 32° e 36° (corrispondenti alla Persia) e per le latitudini 0° (cioè il circolo dell'equatore) e 66°. È completo di alidada e di rete. Il dorso della madre presenta il calendario lunare, secondo l'uso islamico, un quadrato delle ombre e un quadrante. Lo strumento reca la data 496 dell'Egira (1102-1103 dell'età Cristiana) ed è firmato dal suo artefice, Muhammad 'Ibn Abi'l Qasim 'Ibn Bakran, del quale non si hanno notizie. Fu donato al Museo di Storia della Scienza dal Principe fiorentino Tommaso Corsini",
"This small astrolabe carries four tympanums for latitudes 24°/30°, 31°/35°, and 32°/36° (corresponding to Persia), and for latitude 0° (i. e. , the circle of the equator) and 66°. There is an alidade and a rete. The back of the mater displays a lunar calendar, in accordance with Islamic use, a shadow square, and a quadrant. The instrument is dated 496 of the Hegira (1102-1103 of the Christian era) and is signed by its maker, Muhammad 'Ibn Abi'l Qasim 'Ibn Bakran, on whom we have no information. Donated to the Museo di Storia della Scienza by the Florentine Prince Tommaso Corsini"
],
"creator" : [
"http://minerva.atcult.it/rdf/c5738e64-fb77-354a-8fc8-47164105b5f7",
"http://minerva.atcult.it/rdf/3fa79916-cb7f-3574-a3fb-589ca42ebf17"
],
"identifier" : "000000016002",
"issued" : "1102-1103",
"publisher" : "http://minerva.atcult.it/rdf/90310a84-1133-3356-bb3b-647ae1a7d14d",
"title" : "Astrolabio piano",
"numPages" : [
"1 astrolabio",
"1 astrolabe"
],
"placeOfPublication" : "Fattura araba",
"label" : "Astrolabio piano"
},
if you need to have in a result only elements of the #graph array that match the query (if title contains word Astrolabio), you can reach that with the following aggregation framework query:
db.items.aggregate([
{$match: {"#graph.title": /Astrolabio/}},
{$unwind: "$#graph"},
{$match: {"#graph.title": /Astrolabio/} },
{$group: {"_id": "$_id", "#graph": {"$push": "$#graph" } }}
]);
your regex {$regex: /Astrolabio$/} will return only documents with titles that have 'Astrolabio' as the last word is a sentence ("Astrolabio Piano" will not be included as 'Piano' is the last word here).

character error fortran 90

I'm struggling with a small program, I can't find how to correct one mistake.
My program:
program calcul
! ce programme permet d'effectuer des opérations mathématique de base
IMPLICIT NONE
REAL::x,y
character(len=1)::op
character(len=16)::op_msg
write(*,*)"entrer le type d'opération à effectuer(+,-,/,x,*)"
read(*,*)op
write(*,*)"entrer le premier nombre de l'opération"
read(*,*)x
write(*,*)"entrer le deuxième nombre de l'opération"
read(*,*)y
if(op=="+") then
write(*,*)x,"plus",y,"egale",x+y
else if(op=="-")then
write(*,*)x,"moin",y,"egale",x-y
else if ((op==("*").or.("x")) then
write(*,*)x,"multiplie par",y,"egale",x*y
else if (op=="/")then
write(*,*)x,"divise par",y,"egale",x/y
else
write(*,*)"erreur:operation incorrecte"
end if
end program calcul
The error message:
calculette.f90:21.26:
else if ((op==("*").or.("x")) then
1
Error: Invalid character in name at (1)
Any idea? I don't understand why "x" is an invalid character?
else if ((op==("*").or.op==("x")) then
You are evaluating two separate conditions, so each one needs a "left" and "right" side.