Tuukka Lehtonen [Tue, 30 Aug 2022 10:03:08 +0000 (13:03 +0300)]
Set __SCRIPT_PATH__ and __SCRIPT_DIR__ variables in SCL runFromFile
Scripts executed can now read `__SCRIPT_PATH__ :: Maybe Path` and
`__SCRIPT_DIR__ :: Maybe Path` to perform file system resolution logic
based on the ran script's file system location.
Tuukka Lehtonen [Wed, 25 May 2022 20:46:19 +0000 (23:46 +0300)]
Add executionPeriod property for user component SCL scripts
Also added SCL API for setting/getting the execution periods of scripts:
* `Simantics/UserComponent/setUserCOmponentScriptExecutionPeriod
* `Simantics/UserComponent/userComponentTypeScriptExecutionPeriod
Marko Luukkainen [Thu, 28 Apr 2022 10:18:40 +0000 (13:18 +0300)]
NatTable based graph explorer omits background decoration.
With trees, it is not enough to override just BODY style. Also
EVEN_STYLE and ODD_STYLE must be overridden.
Re-use existing style values when possible, so that GE contributions do
not erase default styles, like even/odd row coloring.
Tuukka Lehtonen [Fri, 21 Jan 2022 19:43:40 +0000 (21:43 +0200)]
Fix MappingBase to update and invalidate configurationByComponentId
Previous changes made in #713 only added the cache structure but failed
to update and invalidate when synchronization is performed and the
structure is updated.
Tuukka Lehtonen [Mon, 8 Nov 2021 12:03:22 +0000 (14:03 +0200)]
Add more databoard reading utilities to ByteFileReader
Also add writeDynamicUInt32(byte[] out, int offset, int length) to
Endian class for more direct writing of data to optimize custom
serializer implementations.
Change MappingBase.browseConfiguration to use THashMap.forEachValue
instead of Collection.iterator() for a tighter implementation.
Tuukka Lehtonen [Mon, 30 Mar 2020 22:13:59 +0000 (01:13 +0300)]
Fixed InvertBasicExpressionVisitor bugs with subtractions and divisions
Minus expressions and divisions were both computed the wrong way around,
i.e. a-b as b-a and a/b as b/a.
Consolidated duplicate InvertBasicExpressionVisitor code into single
base class.
Also noticed that the basicexpression parser doesn't parse e.g. `a*5/4`
but parses `a*5 / 4` just fine. Didn't dive into these parser problems
for now. Hopefully we can retire this code entirely at some point in
favor of SCL expressions.
Tuukka Lehtonen [Tue, 4 May 2021 07:45:32 +0000 (10:45 +0300)]
Add ComponentBase.componentId -> ComponentBase cache map in MappingBase
This map is built at the same time as the previously existing
`Map<String, T> configurationBySolverName` with the purpose of allowing
implementations to avoid performing solver-side int -> String lookups in
cases where pure model mapping structure lookup zero GC behavior and
speed is essential.
Tuukka Lehtonen [Wed, 26 Aug 2020 06:59:48 +0000 (09:59 +0300)]
Add utility class org.simantics.modeling.help.HelpContexts
The new class gathers headless code related to reading help context ids
from the database that was previously crammed into a very illogical
package org.simantics.modeling.ui.modelBrowser.handlers.
Fix CopyAdvisorUtil.copy2 to copy IsRelatedTo-statements left out before
This implementation works so that it copies any IsRelatedTo statements
where both the subject and object have been copied during the normal
(old) copy process. The statements are marked as pending during the copy
and post-processed after everything else has been copied.
Tuukka Lehtonen [Thu, 4 Jun 2020 22:33:16 +0000 (01:33 +0300)]
Avoid useless reallocation of empty TreeMaps and map iterators
The problem was that when the database is doing work, MainProgram.run
runs in pretty much busy loop mode and previously it was always
allocating a new TreeMap on each round and also calling Map.entrySet()
to get construct iterators for empty TreeMaps which eventually
accumulates up to somewhat signinificant amount of memory allocated.
Possibly an even more efficient way would be to have the Map be a closed
hashing hashmap instead and then sorting the data for iteration
separately.
Tuukka Lehtonen [Fri, 3 Jan 2020 11:51:33 +0000 (13:51 +0200)]
Added new field TypeId to dependency index for exact type searching
The new field is String-valued and contains a concatenation of the
resource ids of a resource's type hierarchy, separated by a whitespace,
for example `41233 12423 1233`. This field uses the WhitespaceAnalyzer,
i.e. its contents are tokenized by whitespace and thus searches like
`TypeId:41233` will return exactly those resources that are instances of
the type resource `41233`.
This commit also simplifies and fixes some of the existing index
searching code to use this new field instead of the old `Types` field
for type-based searching.
If existing product-code uses the indexing facilities directly and not
through `QueryIndexUtils` or `Instances`, such code will also require
changes to take this new field into use.
See `IndexQueries` to form queries related to this field.
Tuukka Lehtonen [Tue, 18 Dec 2018 14:37:39 +0000 (16:37 +0200)]
Optimized Layer0Utils.getPossibleDefaultBinding
Removed badly named datatype_binging public static field from
Layer0Utils in favor of Bindings.DATATYPE. If you were using the
previous Layer0Utils constant in some place, just replace it.
The problem in the optimized code was that it was constantly converting
SCL types like "Double", "Boolean" etc. to databoard datatypes using the
databoard type parser even though those basic primitive types should
have been already premapped somewhere to prevent the need for any kind
of parsing.
Previously nodes could only return null to say "I have no bounds".
Now it is possible to return GeometryUtils.undefinedBounds() to say
"ignore my bounds" to G2DParentNode.
Also allow customization of the node class used by ElementPainter to
mark selections under "element nodes" through a new configuration class
ElementPainterConfiguration.
This allows e.g. district to use its own node for this purpose to
optimize the scene graph and customize the bounds it returns.
Tuukka Lehtonen [Mon, 4 Nov 2019 14:12:08 +0000 (16:12 +0200)]
Removed trailing newline from clipboard text
When copying text to clipboard from GraphExplorer-based UI controls
(Model Browser, Selection view) using StandardCopyHandler, the produced
text no longer contains a trailing newline.
jsimomaa [Thu, 31 Oct 2019 07:27:35 +0000 (09:27 +0200)]
Fix adding components to configurationBySolverName map in MappingBase
The map is now invalidated (= null) when components are added which
means the map will be recalculated next time when retrieved with
getConfigurationBySolverName.
Tuukka Lehtonen [Tue, 29 Oct 2019 14:42:11 +0000 (16:42 +0200)]
Support reading TG files with shared and non-shared value contexts
This is part of the fix for a nasty corner case in
TransferableGraphFileReader.readTG's deserialization of referable value
data types.
This regression was caused by commit bf495713dbc9dec325f3929889466fa6cd58b541 over 1.5 years ago. The removal
of idContext.clear() was done without proper understanding of the real
issue.
The real issue is that TG's are currently written in two ways by
different codes: with shared and with non-shared value contexts.
Serializing TransferableGraph1 structures using the default Binding will
use shared context for serializing the values Variant array. Thus all TG
files produced by the graph compiler use a shared value context which
eans this class must be used with sharedValueContext set to true. As an
example, <code>true</code> must be used if the corresponding TG file is
written e.g. like this:
DataContainers.writeFile(location
new DataContainer(format,
version,
metadata,
new Variant(TransferableGraph1.BINDING, tg)));
On the other hand, any TG files serialized using more optimized methods
like ModelTransferableGraphSource do not use a shared value context when
writing the file. This means those files cannot be read safely using
standard {@link Binding} at all, and when using this class,
sharedValueContext must be set to false to prevent the import from
corrupting datatype values because the referable parts of datatypes may
get bound to the wrong existing types if the data is read using shared
context.
After this change clients should use readTG(File | InputStream, boolean)
methods instead of readTG to always specify the context sharing setting
explicitly according to how the TG's in question were written.
Tuukka Lehtonen [Thu, 17 Oct 2019 07:52:39 +0000 (10:52 +0300)]
Rid TypicalPropertyTester of database read transactions
After this, the normal workbench invocations of TypicalPropertyTester no
longer perform any database transactions to do their work. DiagramViewer
now has built-in support for doing the required queries based on
IDiagram hints alone.
Added two new user component SCL script simulation stages
1. pre-step: executed during each simulation step,
before native simulation stepping
2. post-step: executed during each simulation step,
after native and all other stepping logics
The purpose of these is to allow simulation step initialization and
finalization with UC SCL scripts.
Allow simulation stop handling in Simantics/Sequences
`StopReason` enumerates supported reasons for simulation stops which is
delivered once to functions registered through `executeWhenStopped`.
It is up to the domain-specific sequence runners to implement the actual
identification of simulation stopping situations and to invoke
AbstractActionContext.stop(StopReason reason) when needed.
Tuukka Lehtonen [Wed, 12 Dec 2018 21:03:41 +0000 (23:03 +0200)]
Fixed target platform problem with missing net.jcip.annotations
It seems that updating eclipse.collections caused
net.jcip.annotations dependency to be removed which meant
the bundle is no longer in the external dependencies P2 site.
* @Optional annotation added duplicate annotations to BindingRequest for
certain classes
* @Identifier annotation was not actually removed from the
BindingRequest
* BindingRequest hashCode calculation used annotation args excluding the
ones possibly found from the clazz.getAnnotations()
* Prevent replacing existing bindings in BindingRepository.classMap
* Remove excessive use of explicit Types/Names constants in search
queries by using public static fields from Dependencies
* Added missing quoting to terms in index searches
* Use DependencyResources function where the Map returned by
Dependencies is not needed
* Fixed some searches to be case-insensitive again
Jussi Koskela [Fri, 26 Apr 2019 08:31:36 +0000 (11:31 +0300)]
Index tokenized lowercase versions of name and types for UI searches
* Added support for different name/label in search parameter selection.
* Fixed resource search to form wildcard query separately for each term.
* Added utility methods to SearchQuery for lower/uppercasing the query
Tuukka Lehtonen [Fri, 9 Nov 2018 12:04:08 +0000 (14:04 +0200)]
Still fixes history collection value band endTime setting and rendering
Previous changes set value band end time to be the same as the next
value band's start time. However this caused the problem that there is
no way of telling during rendering where exactly within the previous
value band did the band's value go out of dead band and since t_end does
not tell us this. This means that line-rendering (not stepped sample
rendering) will get drawn invalidly if t_end > t_begin within a value
band.
The fix was to set t_end to the last timestamp where the value was still
within deadband, i.e:
```
|t0 t0_end | VALUE BAND #0 t0 < t0_end
| | |t1 | VALUE BAND #1 t1 = t1_end
| | |t1_end |
| | | |t2... VALUE BAND #2
ts0----ts1---- ts2------ts3---
v=0 v=0 v=1 v=2
```