-
-
Notifications
You must be signed in to change notification settings - Fork 237
/
LabInterface.scala
46 lines (43 loc) · 1.96 KB
/
LabInterface.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// (C) Uri Wilensky. https://github.com/NetLogo/NetLogo
package org.nlogo.nvm
import org.nlogo.api.{LabProtocol, LabPostProcessorInputFormat}
import org.nlogo.core.WorldDimensions
object LabInterface {
trait Worker {
def addListener(l: ProgressListener)
def addTableWriter(modelFileName: String, initialDims: WorldDimensions, w: java.io.PrintWriter)
def addSpreadsheetWriter(modelFileName: String, initialDims: WorldDimensions, w: java.io.PrintWriter)
def addStatsWriter(modelFileName: String, initialDims: WorldDimensions, w: java.io.PrintWriter, in: LabPostProcessorInputFormat.Format)
def addListsWriter(modelFileName: String, initialDims: WorldDimensions, w: java.io.PrintWriter,
in: LabPostProcessorInputFormat.Format)
def run(testWorkspace: Workspace, fn: ()=>Workspace, threads: Int)
def compile(w: Workspace) // only for testing purposes
}
trait ProgressListener {
def experimentStarted() { }
def experimentAborted() { }
def experimentCompleted() { }
def runStarted(w: Workspace, runNumber: Int, settings: List[(String, Any)]) { }
def measurementsTaken(w: Workspace, runNumber: Int, step: Int, values: List[AnyRef]) { }
def stepCompleted(w: Workspace, step: Int) { }
def runCompleted(w: Workspace, runNumber: Int, steps: Int) { }
def runtimeError(w: Workspace, runNumber: Int, t: Throwable) { }
}
case class Settings(modelPath: String,
protocolName: Option[String],
externalXMLFile: Option[java.io.File],
tableWriter: Option[java.io.PrintWriter],
spreadsheetWriter: Option[java.io.PrintWriter],
statsWriter: Option[(java.io.PrintWriter, String)],
listsWriter: Option[(java.io.PrintWriter, String)],
dims: Option[WorldDimensions],
threads: Int,
suppressErrors: Boolean,
updatePlots: Boolean,
)
}
trait LabInterface {
import LabInterface._
def newWorker(protocol: LabProtocol): Worker
def run(settings: Settings, protocol: LabProtocol, fn: ()=>Workspace)
}