Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
f6919c2a
Commit
f6919c2a
authored
Mar 22, 2013
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working display of througput recalculation, only issue with last box
parent
06a0511e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
12 deletions
+30
-12
dream/platform/__init__.py
dream/platform/__init__.py
+18
-10
ui/src/dream.js
ui/src/dream.js
+12
-2
No files found.
dream/platform/__init__.py
View file @
f6919c2a
...
...
@@ -3,7 +3,9 @@ from flask import request
from
crossdomain
import
crossdomain
from
util
import
deunicodeData
app
=
Flask
(
__name__
)
global
model
global
data
data
=
{
'model'
:
None
,
'simulation_parameters'
:
{}}
@
app
.
route
(
"/"
)
def
welcome
():
...
...
@@ -31,12 +33,11 @@ def someTest():
@
app
.
route
(
"/setModel"
,
methods
=
[
"POST"
,
"OPTIONS"
])
@
crossdomain
(
origin
=
'*'
)
def
setModel
():
global
model
app
.
logger
.
debug
(
'setModel'
)
app
.
logger
.
debug
(
"request.json: %r"
%
(
request
.
json
,))
#model = deunicodeData(request.json)
model
=
request
.
json
app
.
logger
.
debug
(
"model: %r"
%
(
model
,))
data
[
'model'
]
=
request
.
json
app
.
logger
.
debug
(
"model: %r"
%
(
data
[
'model'
]
,))
return
"ok"
@
app
.
route
(
"/setSimulationParameters"
,
methods
=
[
"POST"
,
"OPTIONS"
])
...
...
@@ -45,11 +46,18 @@ def setSimulationParameters():
app
.
logger
.
debug
(
'setSimulationParameters'
)
parameter_dict
=
request
.
json
app
.
logger
.
debug
(
"parameter_dict: %r"
%
(
parameter_dict
,))
data
[
'simulation_parameters'
][
'available_people'
]
=
parameter_dict
return
"ok"
def
_simulate
():
# Well, it's only dummy code now, but we will have to think about
# running simulation later
box_to_enable_list
=
[
1
,
2
,
3
,
7
,
8
,
9
]
available_people_list
=
[
x
for
x
in
parameter_dict
if
parameter_dict
[
x
]]
people_dict
=
data
[
'simulation_parameters'
].
get
(
'available_people'
,
{})
available_people_list
=
[
x
for
x
in
people_dict
if
people_dict
[
x
]]
to_enable
=
len
(
available_people_list
)
>=
6
throughput
=
None
for
box
in
model
[
"box_list"
]:
for
box
in
data
[
'model'
]
[
"box_list"
]:
box
[
"worker"
]
=
None
box
[
"enabled"
]
=
False
if
int
(
box
[
"id"
][
len
(
"window"
):])
in
box_to_enable_list
:
...
...
@@ -59,17 +67,17 @@ def setSimulationParameters():
if
throughput
is
None
:
throughput
=
box
[
"throughput"
]
throughput
=
min
(
throughput
,
box
[
"throughput"
])
app
.
logger
.
debug
(
'box and throughput : %r, %r'
%
(
box
,
throughput
))
if
throughput
is
None
:
throughput
=
0
model
[
"throughput"
]
=
throughput
return
"ok"
data
[
'model'
][
"throughput"
]
=
throughput
@
app
.
route
(
"/getModel"
,
methods
=
[
"GET"
,
"OPTIONS"
])
@
crossdomain
(
origin
=
'*'
)
def
getModel
():
global
model
app
.
logger
.
debug
(
'getModel'
)
return
jsonify
(
model
)
_simulate
()
return
jsonify
(
data
[
'model'
])
if
__name__
==
"__main__"
:
main
()
ui/src/dream.js
View file @
f6919c2a
...
...
@@ -63,6 +63,8 @@
};
priv
.
initDialog
=
function
()
{
// code to allow changing values on connections. For now we assume
// that it is throughput. But we will need more generic code
var
throughput
=
$
(
"
#throughput
"
),
allFields
=
$
(
[]
).
add
(
throughput
),
tips
=
$
(
"
.validateTips
"
);
...
...
@@ -104,7 +106,7 @@
modal
:
true
,
buttons
:
{
"
Validate
"
:
function
()
{
var
bValid
=
true
;
var
bValid
=
true
,
i
,
i_length
,
box
;
allFields
.
removeClass
(
"
ui-state-error
"
);
console
.
log
(
"
going to check troughput val
"
,
throughput
.
val
());
...
...
@@ -113,7 +115,15 @@
if
(
bValid
)
{
console
.
log
(
"
new value is ok...
"
,
throughput
.
val
());
console
.
log
(
"
dialog_connection
"
,
priv
.
dialog_connection
);
// Update the model with new value
i_length
=
model
.
box_list
.
length
;
for
(
i
=
0
;
i
<
i_length
;
i
++
)
{
box
=
model
.
box_list
[
i
];
if
(
box
.
id
===
priv
.
dialog_connection
.
sourceId
)
{
box
.
throughput
=
parseInt
(
throughput
.
val
(),
10
);
}
}
priv
.
setModel
();
$
(
this
).
dialog
(
"
close
"
);
}
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment