Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into jay/reflectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Jay Billings committed Feb 23, 2015
2 parents bbf0eb1 + 7a390d4 commit 57a6f2a
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 133 deletions.
Expand Up @@ -12,14 +12,13 @@
*******************************************************************************/
package org.eclipse.ice.caebat.launcher;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Scanner;

import javax.xml.bind.annotation.XmlRootElement;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.form.AllowedValueType;
import org.eclipse.ice.datastructures.form.DataComponent;
import org.eclipse.ice.datastructures.form.Entry;
Expand All @@ -28,11 +27,6 @@
import org.eclipse.ice.io.ips.IPSReader;
import org.eclipse.ice.io.ips.IPSWriter;
import org.eclipse.ice.item.jobLauncher.JobLauncher;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

/**
* <!-- begin-UML-doc -->
Expand All @@ -51,7 +45,7 @@ public class CaebatLauncher extends JobLauncher {
* The execution command
*/
private String fullExecCMD;

/**
* The default CAEBAT home directory.
*/
Expand Down Expand Up @@ -155,7 +149,7 @@ public void setupForm() {
protected void setup() {
this.setName("Use custom key-value pair file?");
this.tag = "MODE";
this.setDescription("Time loop's mode. Can be Regular (true) or Explicit (false)");
this.setDescription("Allows the use of a customized KV Pair file generated by ICE");
this.defaultValue = "false";
this.value = this.defaultValue;
this.allowedValues = new ArrayList<String>();
Expand Down Expand Up @@ -193,25 +187,6 @@ protected void setup() {
*/
public FormStatus process(String actionName) {

// begin-user-code
/*
* This section will be used in future iterations String separator =
* System.getProperty("file.separator"); IPSReader reader = new
* IPSReader(); IPSWriter writer = new IPSWriter();
*
* DataComponent fileComponent = (DataComponent) form.getComponent(1);
* Entry inputFileEntry = fileComponent.retrieveEntry("Input File");
*
* IPath fileIPath = new Path(project.getLocation().toOSString() +
* separator + inputFileEntry.getValue()); IFile inputFile =
* ResourcesPlugin.getWorkspace().getRoot().getFile(fileIPath);
* ArrayList<Entry> simRootMatches = reader.findAll(inputFile,
* "SIM_ROOT=.*"); dataDir =
* simRootMatches.get(0).getName().split("=")[1];
*
* writer.replace(inputFile, "SIM_ROOT=.*", "SIM_ROOT=" +
* getLaunchDirectory());
*/
// Local Declarations
String separator = System.getProperty("file.separator");
IPSReader reader = new IPSReader();
Expand Down Expand Up @@ -272,13 +247,11 @@ public FormStatus process(String actionName) {
String mvKVPairFile = "";
if (kvPairFileEntry.getValue() != "false") {
String kvFileName = fileComponent.retrieveEntry("Key-value pair file").getValue();
writer.replace(inputFile, "input_keyvalue", kvFileName);
//writer.replace(inputFile, "input_keyvalue", kvFileName);
setKVPerms = "chmod 775 " + kvFileName + " && ";
backupKVFile = "mv input/input_keyvalue input/input_keyvalue.bak && ";
mvKVPairFile = "mv " + kvFileName + " input/input_keyvalue && ";
}



// Pull some information from the form
TableComponent hostTable = (TableComponent) form.getComponent(4);
Expand Down Expand Up @@ -313,18 +286,18 @@ public FormStatus process(String actionName) {
*/
public void update(IUpdateable component) {
refreshProjectSpace();
super.update(component);

// Determine whether the file selector needs to be added to or removed from the form
if (component.getName() == "Use custom key-value pair file?"
&& ((Entry) component).getValue() == "true") {
addInputType("Key-value pair file", "keyValueFile",
"Key-value pair with case parameters", ".dat");
} else if (component.getName() == "Use custom key-value pair file?"
&& ((Entry) component).getValue() == "false") {
removeInputType("Key-value pair file");
}

if (component instanceof Entry) {
// Determine whether the file selector needs to be added to or removed from the form
if (component.getName() == "Use custom key-value pair file?"
&& ((Entry) component).getValue() == "true") {
addInputType("Key-value pair file", "keyValueFile",
"Key-value pair with case parameters", ".dat");
} else if (component.getName() == "Use custom key-value pair file?"
&& ((Entry) component).getValue() == "false") {
DataComponent fileComponent = (DataComponent) form.getComponent(1);
fileComponent.deleteEntry("Key-value pair file");
}
}
}

/**
Expand Down
21 changes: 12 additions & 9 deletions src/org.eclipse.ice.io/src/org/eclipse/ice/io/ips/IPSReader.java
Expand Up @@ -107,12 +107,15 @@ public Form read(IFile ifile) {
ArrayList<String> names = new ArrayList<String>();

// Read in each of the ports individually
for (int i = 0; i < numberPorts; i++) {
String name = "";
while (!name.equals("TIME_LOOP")) {
DataComponent ipsComponent = loadComponent(iniIterator);
ipsComponents.add(ipsComponent);
names.add(ipsComponent.getName());
name = ipsComponent.getName();
if (!name.equals("TIME_LOOP")) {
ipsComponents.add(ipsComponent);
names.add(ipsComponent.getName());
}
}

// Build a MasterDetailsComponent out of the DataComponents
MasterDetailsComponent portsMaster = buildMasterDetailsComponent(ipsComponents);

Expand Down Expand Up @@ -462,6 +465,10 @@ private DataComponent loadComponent(Iterator<String> it) {
portComponent.setId(currID);
currID++;

if (portComponent.getName().equals("TIME_LOOP")) {
return portComponent;
}

// Read parameters until reaching a whitespace line that separates ports
while (line.trim().length() > 0) {
// The format in this section is: KEY = VALUE # Comment
Expand Down Expand Up @@ -518,7 +525,7 @@ private MasterDetailsComponent buildMasterDetailsComponent(
.setDescription("Setup for each of the ports in the simulation.");
String portName;
int masterId;

// Set the allowed ports so that users don't try to go too far and end
// up with settings that don't exist
String[] allowedPortNames = { "INIT", "INIT_STATE", "AMPERES_THERMAL",
Expand Down Expand Up @@ -594,10 +601,6 @@ private DataComponent loadTimeLoopComponent(Iterator<String> it) {
return null;
}

while (!line.contains("[TIME_LOOP]") && it.hasNext()) {
line = it.next();
}

// Pull the port name and start parsing through the parameters
timeLoopData.setName("Time Loop Data");
timeLoopData.setDescription("");
Expand Down

0 comments on commit 57a6f2a

Please sign in to comment.