This repository has been archived by the owner on Mar 13, 2020. It is now read-only.
forked from KNMI/impactwps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinaryoperatorfornumbers_10sec.py
61 lines (46 loc) · 2.64 KB
/
binaryoperatorfornumbers_10sec.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from pywps.Process.Process import WPSProcess
class Process(WPSProcess):
def __init__(self):
# init process
WPSProcess.__init__(self,
identifier="binaryoperatorfornumbers_10sec", #the same as the file name
title="Perform operation on two numbers 10 seconds",
version = "1.0",
storeSupported = "true",
statusSupported = "true",
abstract="Performs operation on two numbers and returns the answer, updates every second its status for 10 seconds.",
grassLocation =False)
self.inputa = self.addLiteralInput(identifier="inputa",
title="Input 1",
abstract="Input 1",
default = 2.0,
type = type(1.2))
self.inputb = self.addLiteralInput(identifier="inputb",
title="Input 2",
abstract="Input 2",
default = 3.0,
type = type(1.2))
self.operator = self.addLiteralInput(identifier = 'operator',
title = 'operator',
type=type("String"),
default = 'add')
self.operator.values = ["add","substract","divide","multiply"]
self.Answer=self.addLiteralOutput(identifier = "answer",
title = "Binary operator result")
def execute(self):
import time
self.status.set("Preparing....", 0)
for i in xrange(1, 11):
time.sleep(1)
self.status.set("Thinking.....", (i-1)*10)
answer = 0
if(self.operator.getValue() == "add"):
answer = self.inputa.getValue()+self.inputb.getValue()
if(self.operator.getValue() == "substract"):
answer = self.inputa.getValue()-self.inputb.getValue()
if(self.operator.getValue() == "multiply"):
answer = self.inputa.getValue()*self.inputb.getValue()
if(self.operator.getValue() == "divide"):
answer = self.inputa.getValue()/self.inputb.getValue()
#The final answer
self.Answer.setValue(answer)