I need to model a system as a timed automaton with UPPAAL and I'm really puzzled with the way UPPAAL manages clocks and guards according to elapsed time: it looks like UPPAAL just ignores clock guards!
I suppose my problem is that I'm approaching modelling from a very "physical" approach, and so I'm facing this kind of problems.
So here comes a trivial automaton. When run on UPPAAL simulation, I would expect that it loops forever between initial and A locations, never going to B. But this is not the case: it alternates randomly between A and B (at least using the latest UPPAAL snapshot; I cannot try the release, as there's no Linux 64 version).
So what I'm missing? How really UPPAAL treats clock guards?
What I was trying to do when I first encountered this issue is to model a timeout, so the automaton takes a different edge if the guard of the nominal behavior is not meet before 30 seconds.
Thank you a lot
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'>
<nta>
<declaration>// Place global declarations here.
clock t;</declaration>
<template>
<name x="5" y="5">Template</name>
<declaration>// Place local declarations here.
</declaration>
<location id="id0" x="153" y="8">
<name x="170" y="0">B</name>
</location>
<location id="id1" x="0" y="119">
<name x="-8" y="136">A</name>
</location>
<location id="id2" x="0" y="0">
</location>
<init ref="id2"/>
<transition>
<source ref="id0"/>
<target ref="id2"/>
<label kind="assignment" x="60" y="-55">t:=0</label>
<nail x="153" y="-8"/>
<nail x="42" y="-102"/>
</transition>
<transition>
<source ref="id1"/>
<target ref="id2"/>
<label kind="assignment" x="-135" y="55">t:=0</label>
<nail x="-153" y="-8"/>
</transition>
<transition>
<source ref="id2"/>
<target ref="id0"/>
<label kind="guard" x="93" y="-17">t > 30</label>
</transition>
<transition>
<source ref="id2"/>
<target ref="id1"/>
<label kind="guard" x="0" y="25">t<30</label>
</transition>
</template>
<system>// Place template instantiations here.
// List one or more processes to be composed into a system.
system Template;
</system>
<queries>
<query>
<formula>sup: t
</formula>
<comment>
</comment>
</query>
</queries>
</nta>
Sorry, I got a solution for this long time ago on uppaal Yahoo group. I paste the answer here, so it can be useful for others:
There is nothing special in your model.
You are probably expecting "as soon as possible" semantics where the
automaton would take the transition as soon as it becomes enabled. Timed
automaton is not like that: if there is no invariant (as in your example),
then the timed automaton is allowed to delay as much as possible.
Consequently, the behavior of your automaton includes non-deterministic
choices: either to delay (let time pass) or take the transition. Then the
whole point of model-checker like Uppaal is to explore all possibilities
and that's why you see both edges (with t<30 and t>30) being exercised.
Please note that the clock values (constraints) are different when either
transition is taken, which means that they are executed at different
(mutually exclusive) times.
If you want something definitely to happen within 30 time units, i.e. do
not allow time to pass beyond this point without anything happening and
you have some transition enabled, then you need to add an invariant t<30
(double-click the location and enter this expression into Invariant text
field).
Hope this helps to someone!
Related
Lets say that a task needs to be done and there are no data model changes needed(i.e items.xml does not need to be touched).
For example a new Interceptor is needed for an existing Item Type. In this case I just need a new spring bean and a new Java class.
After I do the changes, If I run an "ant build" it takes approximately 1:30(one minute and a half), sometimes even more than that.
From what I noticed Hybris tries to check every extension that is included in localExtension.xml with their required extensions as well, and that is taking a lot of time.
How can I perform a faster build ? It should not take that much time since the only thing that is needed in my Interceptor case is to compile the new Interceptor class, and that's it.
I understand that when data model is changed the models.jar needs to be deleted, the new sources need to be generated and compiled in a new models.jar and that requires time. But in the more simple scenario it should work a lot faster.
PS: I know about JRebel but this question addresses the cases in which the developer does not have JRebel.
In platform/build.xml add below ant target:
<target name="compileExtensions" description="Compiles only the provided extensions">
<compile_only_specified_extensions/>
</target>
In platform/resources/ant/compiling.xml add the macro definition:
<macrodef name="compile_only_specified_extensions">
<sequential>
<foreachextprovidedincli>
<do>
<if>
<not>
<isset property="ext.#{extname}.warextension" />
</not>
<then>
<extension_compile extname="#{extname}" />
</then>
<else>
<external_extension_build extname="#{extname}"/>
</else>
</if>
</do>
</foreachextprovidedincli>
</sequential>
</macrodef>
Define foreachextprovidedincli in platform/resources/ant/util.xml
<macrodef name="foreachextprovidedincli">
<element name="do" optional="false" />
<attribute name="param" default="extname" />
<sequential>
<for list="${extensions.to.compile}" param="#{param}" delimiter=";">
<sequential>
<do />
</sequential>
</for>
</sequential>
</macrodef>
Now what I simply have to do to compile my classes is run the following command:
ant compileExtensions -Dextensions.to.compile="extensionName1;extensionName2;extensionName3"
With above command the build was reduced to 4 seconds.
I've been spending a lot of time trying to track down memory leaks in our Xamarin.Forms app on Android. After a lot of blind alleys and false dawns, I think I may have come across something which is causing the problem.
Using Xamarin Profiler, I can see that as soon as I create a Style and apply it to a control (or in fact just an implicit style), we get Multiple WeakReferences remaining 'Live' - i.e. not garbage collected.
Note that I assume that the objects to which they refer have been GC'd (because the reference to the object is weak), but the WeakReferences themselves are remaining.
Now of course WeakReferences are small I know - but when you have hundreds created on every iteration of a page push/pop, then the memory adds up and we have a significant leak.
Here are the details.
Using Xamarin.Forms 2.3.4.270 (we haven't upgraded because we want to keep with known issues!)
Running on Android - physical device.
App.xaml:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:ProfiledFormsApp2;assembly=ProfiledFormsApp2"
x:Class="ProfiledFormsApp2.App">
<Application.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="FontSize" Value="Large" />
<Setter Property="TextColor" Value="Blue" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
Page XAML:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage Title="Plain Page" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ProfiledFormsApp2.PlainPage">
<ContentPage.Content>
<StackLayout>
<StackLayout Orientation="Horizontal">
<Label Text="Core Navigation"/>
<Label Text="Number of items:" />
<Label Text="{Binding ItemsCount}" />
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
When I navigate to the above page and back 3 times, we have the following WeakReference (and related) classes created - the screenshot below is from a Profiler snapshot.
Note we have 55 WeakReferences. Drilling into these shows:
What is interesting is that these WeakReferences seem to be created as part of Behavior and Trigger attaching. Looking at the call tree for the top one gives:
So it appears that the WeakReference was created as part of setting a BindableObject's value and the subsequent setting of the Style.
And it also appears that the WeakReference is still in memory and being referenced by something - the Behavior collection?
Using Profiler, I'm can see that we don't have Labels remaining un GC'd. It seems to be something in the Theme/Behavior/Trigger processing.
I haven't looked at the Xamarin.Forms code on GitHub yet - that might have to be my next action.
Has anyone observed this or got a solution?
I am not sure about the implicit styles to the controls but for the explicit styles you can remove them while page is out of scope OR disappearing.
Example, we applied an explicit style to button
<Button x:Name="btnSave" Style="{StaticResource SaveButtonStyle}" Content="Save"/>
protected override void OnDisappearing()
{
btnSave.Style = null;
base.OnDisappearing();
}
Same can be done with Triggers and Behaviors as well (You can clear them).
I think for the implicit styles, there is something within the code of framework only. We can not identify how default style of control is attached with control as default.
I have one requirement, I am new to XSLT language so I am looking for your help for my below requirement.
Below is the input xml payload
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:sendfile xmlns:ns0="namepsace here">
<Delivery>
<IssueDateTime>2016-05-24T09:25:19z</IssueDateTime>
<Item>
<order>
<orderChar>
<orderName />
<orderVal />
</orderChar>
<orderInfo>
<Product />
<Batch />
<Qty />
<UOM />
</orderInfo>
</order>
</Item>
</Delivery>
so in the file orderchar node and orderInfo node will repeat multiple times based on that in receiver structure 2 nodes should repeat. for example
orderchar segment is repeating 20 times, in receiver also E1ADRM segment should repeat same number of times.
order info also same case in receiver E1DRM segment should repeat same number of times.In case any of the node will not come in receiver also the segment should not populate.
I think we can do this some value of select with that syntax. could you please help me on this.
I tried with below code and able to generate the node. but when repeated nodes are coming the repeated receiver nodes are not populating.
<ns0:if test="count(./order/orderChar)!=0">
<E1EDL12 SEGMENT="1">
<ATNAM>
<ns0:value-of select="./orderChar/orderName"/>
</ATNAM>
<ATWRT>
<ns0:value-of select="./orderChar/orderName"/>
</ATWRT>
</E1EDL12>
above code tried for only for one segment.could you please suggest what modification I have to do to populate multiple times.
Regards,
Janardhan
You really haven't made your requirement very clear, but my guess would be that you want something like:
<xsl:for-each select="orderChar">
<ATNAM>
<xsl:value-of select="orderName"/>
</ATNAM>
<ATWRT>
<xsl:value-of select="./orderChar/orderName"/>
</ATWRT>
</xsl:for-each>
I have to call 2 different XSL depending on some basis set in the input XML .
I don't want to write 2 separate transformer for this task. The current Code has been written like this
<int:router input-channel="inputchannel"
default-output-channel="outputChannel" expression="headers.get('someValue')">
<int:mapping value="x" channel="xChannel" />
<int:mapping value="y" channel="yChannel" />
</int:router>
<int-xml:xslt-transformer inputChannel="xChannel" output-channel= "output"
xsl-resource="xRelated.xsl" />
<int-xml:xslt-transformer inputChannel="yChannel" output-channel="output"
xsl-resource="yRelated.xsl" />
However , this seems to be a dirty solution as this is just a sample . I will be having 14 different type of XSLs. Does anyone have an idea,how can I re factor this.
The Spring Integration XsltPayloadTransformer relies on TransformerFactory abstraction which preduces Templates based on Source from underlying XSTL.
So, looks like there is no choice to have just only one component who can handle several XSLT at once.
It would be great, if know other XSLT engine which can provide desired solution, but it hasn't to be based on standard TransformerFactory.
My XML (simplified) is like this:
<Actions>
<Action Id="1">
</Action>
<Action Id="2">
<DoSomething>
<ActionRef ActionId="1" /> <!-- valid -->
</DoSomething>
</Action>
</Actions>
The ActionId attribute value references the Id attribute value of the Action element. I've already set up a foreign key constraint in the XSD, and it works correctly.
I want to prevent self-referencing values in the foreign field, like this:
<Actions>
<Action Id="1">
</Action>
<Action Id="2">
<DoSomething>
<ActionRef ActionId="2" /> <!-- invalid -->
</DoSomething>
</Action>
</Actions>
Of course, this can easily be done within the application that processes the XML, and I'll fall back on that if what I'm asking for isn't possible, but I'd much rather have this done automatically by the validation process.
I tried adding [not(#ActionId = ../#Id)] to the foreign key selector XPath query, but that isn't valid in that context (nor am I sure it's correct either). Other than that, I have no idea what else to try, and it doesn't look like many people on the internets even set up foreign key relationships in their XSDs, let alone prevent this kind of situation (I found nothing on this exact topic).
It cannot be done - the selector syntax for XSD constraints is very limited. Other alternatives may include Schematron, which should be reasonable to integrate assuming your runtime has access to an XSLT processor. The effort could pay off is you decide to add more validation rules separate from the code of the application that processes the XML.