Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Pontesegger2015-10-23 06:42:40 +0000
committerChristian Pontesegger2015-10-23 06:43:38 +0000
commit2b1aa84f6291a52165372938428dddf5dfb7d2b4 (patch)
treea4fc010d616620488c2b890e04a90e4ffd528da4 /Jython Examples with Eclipse ICE
parent1f7278e9e811b11f7aaae8b511af5bf4eeca23bb (diff)
downloadorg.eclipse.ease.scripts-2b1aa84f6291a52165372938428dddf5dfb7d2b4.tar.gz
org.eclipse.ease.scripts-2b1aa84f6291a52165372938428dddf5dfb7d2b4.tar.xz
org.eclipse.ease.scripts-2b1aa84f6291a52165372938428dddf5dfb7d2b4.zip
Bug 480021: EASE scripts for working with Jython and Eclipse ICE
added new sample scripts to show EASE/ICE interaction Change-Id: Ia76b565bab66d3092dd9bca5f690ca4c7fff0428 Signed-off-by: Christian Pontesegger <christian.pontesegger@web.de>
Diffstat (limited to 'Jython Examples with Eclipse ICE')
-rw-r--r--Jython Examples with Eclipse ICE/.project11
-rw-r--r--Jython Examples with Eclipse ICE/createAndEditPython.py47
-rw-r--r--Jython Examples with Eclipse ICE/createAndProcessPython.py35
-rw-r--r--Jython Examples with Eclipse ICE/iterateChangeParameterPython.py52
-rw-r--r--Jython Examples with Eclipse ICE/listFromScratchPython.py105
5 files changed, 250 insertions, 0 deletions
diff --git a/Jython Examples with Eclipse ICE/.project b/Jython Examples with Eclipse ICE/.project
new file mode 100644
index 0000000..9303d6d
--- /dev/null
+++ b/Jython Examples with Eclipse ICE/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Jython Examples with Eclipse ICE</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
diff --git a/Jython Examples with Eclipse ICE/createAndEditPython.py b/Jython Examples with Eclipse ICE/createAndEditPython.py
new file mode 100644
index 0000000..98dc552
--- /dev/null
+++ b/Jython Examples with Eclipse ICE/createAndEditPython.py
@@ -0,0 +1,47 @@
+ # ****************************************************************************
+ # Copyright (c) 2015 UT-Battelle, LLC.
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Initial API and implementation and/or initial documentation - Kasper
+ # Gammeltoft, Jay Jay Billings
+ #
+ # This is an example script designed to show how to use ease with ICE. It
+ # creates a new Reflectivity Model and processes it, but also edits the input
+ # to the table beforehand.
+ # ****************************************************************************
+
+# Load the Platform module for accessing OSGi services
+loadModule('/System/Platform')
+
+# Get the core service from ICE for creating and accessing objects.
+coreService = getService(org.eclipse.ice.core.iCore.ICore);
+
+# Create the reflectivity model to be used and get its reference. The create item
+# method will return a string representing the number of that item, so use int() to
+# convert it to an integer.
+reflectModel = coreService.getItem(int(coreService.createItem("Reflectivity Model")))
+
+# Gets the list component used as the data for the table (is on tab 2)
+listComp = reflectModel.getComponent(2)
+
+# Gets the third material and sets its thickness to 400
+mat1 = listComp.get(2)
+mat1.setProperty("Thickness (A)", 400)
+
+# Get the total thickness and set the second material's thickness to depend
+# on the thicknesses of the other materials
+totThickness = 0
+for i in xrange(0, listComp.size() - 1):
+ if(i != 1):
+ totThickness += listComp.get(i).getProperty("Thickness (A)")
+
+# Set the thickness of the second material so that the total sums to 1000 (A)
+listComp.get(1).setProperty("Thickness (A)", 1000-totThickness);
+
+
+# Finally process the model to get the results.
+coreService.processItem(reflectModel.getId(), "Calculate Reflectivity", 1);
diff --git a/Jython Examples with Eclipse ICE/createAndProcessPython.py b/Jython Examples with Eclipse ICE/createAndProcessPython.py
new file mode 100644
index 0000000..6f9271f
--- /dev/null
+++ b/Jython Examples with Eclipse ICE/createAndProcessPython.py
@@ -0,0 +1,35 @@
+
+ # ****************************************************************************
+ # Copyright (c) 2015 UT-Battelle, LLC.
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Initial API and implementation and/or initial documentation - Kasper
+ # Gammeltoft, Jay Jay Billings
+ #
+ # This is an example script designed to show how to use ease with ICE. It
+ # creates a new Reflectivity Model and processes it, using the default mock
+ # data and inputs.
+ # ****************************************************************************
+
+# Load the Platform module for accessing OSGi services
+loadModule('/System/Platform')
+
+# Get the core service from ICE for creating and accessing objects.
+coreService = getService(org.eclipse.ice.core.iCore.ICore);
+
+# Create the reflectivity model to be used and get its reference. The create item
+# method will return a string representing the number of that item, so use int() to
+# convert it to an integer.
+reflectModel = coreService.getItem(int(coreService.createItem("Reflectivity Model")))
+
+# This is usually where you would do your own customization and automation regarding
+# the reflectivity model you just created. Maybe change the layers, or do some custom
+# calculations.
+
+
+# Finally process the model to get the results.
+coreService.processItem(reflectModel.getId(), "Calculate Reflectivity", 1);
diff --git a/Jython Examples with Eclipse ICE/iterateChangeParameterPython.py b/Jython Examples with Eclipse ICE/iterateChangeParameterPython.py
new file mode 100644
index 0000000..637ebf3
--- /dev/null
+++ b/Jython Examples with Eclipse ICE/iterateChangeParameterPython.py
@@ -0,0 +1,52 @@
+
+ # ****************************************************************************
+ # Copyright (c) 2015 UT-Battelle, LLC.
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Initial API and implementation and/or initial documentation - Kasper
+ # Gammeltoft, Jay Jay Billings
+ #
+ # This is an example script designed to show how to use ease with ICE. It
+ # creates several new Reflectivity Models and changes the thickness parameter
+ # to show the effect that creates.
+ # ****************************************************************************
+
+# Load the Platform module for accessing OSGi services
+loadModule('/System/Platform')
+
+# Get the core service from ICE for creating and accessing objects.
+coreService = getService(org.eclipse.ice.core.iCore.ICore);
+
+# Set a initial value for the thickness of the nickel layer. This will be doubled
+# for each iteration to show how this parameter effects the model
+nickelThickness = 250;
+
+for i in xrange(1, 5):
+ # Create the reflectivity model to be used and get its reference. The create item
+ # method will return a string representing the number of that item, so use int() to
+ # convert it to an integer.
+ reflectModel = coreService.getItem(int(coreService.createItem("Reflectivity Model")))
+
+ # Get the nickel layer from the model. It should be in the list, which is component 2,
+ # and it is the third layer in that list (which is item 2 as the list is zero based).
+ listComp = reflectModel.getComponent(2);
+ nickel = listComp.get(2);
+
+ nickel.setProperty("Thickness (A)", nickelThickness);
+
+ nickelThickness += 250;
+
+ # Finally process the model to get the results.
+ coreService.processItem(reflectModel.getId(), "Calculate Reflectivity", 1);
+
+
+
+
+
+
+
+
diff --git a/Jython Examples with Eclipse ICE/listFromScratchPython.py b/Jython Examples with Eclipse ICE/listFromScratchPython.py
new file mode 100644
index 0000000..f0053ba
--- /dev/null
+++ b/Jython Examples with Eclipse ICE/listFromScratchPython.py
@@ -0,0 +1,105 @@
+
+ # ****************************************************************************
+ # Copyright (c) 2015 UT-Battelle, LLC.
+ # All rights reserved. This program and the accompanying materials
+ # are made available under the terms of the Eclipse Public License v1.0
+ # which accompanies this distribution, and is available at
+ # http://www.eclipse.org/legal/epl-v10.html
+ #
+ # Contributors:
+ # Initial API and implementation and/or initial documentation - Kasper
+ # Gammeltoft, Jay Jay Billings
+ #
+ # This is an example script designed to show how to use ease with ICE. It
+ # creates a new Reflectivity Model and shows how to customize and build up
+ # the layers in the model from scratch.
+ # ****************************************************************************
+
+# Needed imports from ICE
+from org.eclipse.ice.datastructures.form import Material
+
+# Load the Platform module for accessing OSGi services
+loadModule('/System/Platform')
+
+# Get the core service from ICE for creating and accessing objects.
+coreService = getService(org.eclipse.ice.core.iCore.ICore);
+
+# Create the reflectivity model to be used and get its reference. The create item
+# method will return a string representing the number of that item, so use int() to
+# convert it to an integer.
+reflectModel = coreService.getItem(int(coreService.createItem("Reflectivity Model")))
+
+# Gets the list component used as the data for the table (is on tab 2)
+listComp = reflectModel.getComponent(2)
+
+# Now we want to build up the list from our own data, so we can do that here.
+
+# The first step would be to clear the list so that we can start adding to it. Clearing
+# the list requires the locks as multiple operations are happening and we need to
+# protect the list from multiple threads trying to access it at the same time.
+listComp.getReadWriteLock().writeLock().lock()
+listComp.clear()
+listComp.getReadWriteLock().writeLock().unlock()
+
+# Create the layer of air
+air = Material()
+air.setName("Air")
+air.setProperty("Material ID", 1)
+air.setProperty("Thickness (A)", 200)
+air.setProperty("Roughness (A)", 0)
+air.setProperty(Material.SCAT_LENGTH_DENSITY, 0)
+air.setProperty(Material.MASS_ABS_COHERENT, 0)
+air.setProperty(Material.MASS_ABS_INCOHERENT, 0)
+
+# Create the Aluminum Oxide layer
+AlOx = Material()
+AlOx.setName("AlOx")
+AlOx.setProperty("Material ID", 2)
+AlOx.setProperty("Thickness (A)", 25)
+AlOx.setProperty("Roughness (A)", 10.2)
+AlOx.setProperty(Material.SCAT_LENGTH_DENSITY, 1.436e-6)
+AlOx.setProperty(Material.MASS_ABS_COHERENT, 6.125e-11)
+AlOx.setProperty(Material.MASS_ABS_INCOHERENT, 4.47e-12)
+
+# Create the Aluminum layer
+Al = Material()
+Al.setName("Al")
+Al.setProperty("Material ID", 3)
+Al.setProperty("Thickness (A)", 500)
+Al.setProperty("Roughness (A)", 11.4)
+Al.setProperty(Material.SCAT_LENGTH_DENSITY, 2.078e-6)
+Al.setProperty(Material.MASS_ABS_COHERENT, 2.87e-13)
+Al.setProperty(Material.MASS_ABS_INCOHERENT, 1.83e-12)
+
+# Create the Aluminum Silicate layer
+AlSiOx = Material()
+AlSiOx.setName("AlSiOx")
+AlSiOx.setProperty("Material ID", 4)
+AlSiOx.setProperty("Thickness (A)", 10)
+AlSiOx.setProperty("Roughness (A)", 17.2)
+AlSiOx.setProperty(Material.SCAT_LENGTH_DENSITY, 1.489e-6)
+AlSiOx.setProperty(Material.MASS_ABS_COHERENT, 8.609e-9)
+AlSiOx.setProperty(Material.MASS_ABS_INCOHERENT, 6.307e-10)
+
+# Create the Silicon layer
+Si = Material()
+Si.setName("Si")
+Si.setProperty("Material ID", 5)
+Si.setProperty("Thickness (A)", 100)
+Si.setProperty("Roughness (A)", 17.5)
+Si.setProperty(Material.SCAT_LENGTH_DENSITY, 2.07e-6)
+Si.setProperty(Material.MASS_ABS_COHERENT, 4.7498e-11)
+Si.setProperty(Material.MASS_ABS_INCOHERENT, 1.9977e-12)
+
+# Add all of the materials back to the list (in top to bottom order)
+listComp.getReadWriteLock().writeLock().lock()
+listComp.add(air);
+listComp.add(AlOx);
+listComp.add(Al);
+listComp.add(AlSiOx);
+listComp.add(Si);
+listComp.getReadWriteLock().writeLock().unlock()
+
+# Finally process the model to get the results.
+coreService.processItem(reflectModel.getId(), "Calculate Reflectivity", 1);
+

Back to the top