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
b2918e6f
Commit
b2918e6f
authored
Jun 16, 2015
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReadJSShifts now only for operators, minor correction
parent
664d0895
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
37 deletions
+41
-37
dream/plugins/JobShop/ReadJSShifts.py
dream/plugins/JobShop/ReadJSShifts.py
+41
-37
No files found.
dream/plugins/JobShop/ReadJSShifts.py
View file @
b2918e6f
...
...
@@ -98,6 +98,9 @@ class ReadJSShifts(plugin.InputPreparationPlugin, TimeSupportMixin):
breakStart
,
breakEnd
=
timePair
timeStartList
.
append
(
breakEnd
)
timeEndList
.
insert
(
0
,
breakStart
)
# sort the list before proceeding
timeEndList
.
sort
()
timeStartList
.
sort
()
#if it is the current row is an extended row for the information belonging to a resource, and no resource name is entered
if
line
[
0
]:
entityID
=
line
[
0
].
split
(
"-"
)[
0
]
...
...
@@ -142,7 +145,7 @@ class ReadJSShifts(plugin.InputPreparationPlugin, TimeSupportMixin):
#create default pattern for all operators (10 days long)
timeStartList
=
[]
timeEndList
=
[]
for
dayNumber
in
range
(
0
,
1
0
):
for
dayNumber
in
range
(
0
,
2
0
):
startTime
=
"08:00"
endTime
=
"18:00"
upDate
=
now
.
date
()
+
datetime
.
timedelta
(
days
=
dayNumber
)
...
...
@@ -167,43 +170,44 @@ class ReadJSShifts(plugin.InputPreparationPlugin, TimeSupportMixin):
# ================================================================
for
node
,
node_data
in
nodes
.
items
():
modifiedDefaultDays
=
[]
# the days of the defaultShiftPattern that have been modified according to the exceptionShiftPattern
if
node
in
exceptionShiftPattern
:
for
index1
,
exception
in
enumerate
(
exceptionShiftPattern
[
node
]):
# XXX think of the case where the exception starts one day and finishes the next
# calculate the time difference in hours from the end of the first day to the end of the exception
# check if we are still in the first day
if
hoursToEndFirstDay
.
total_seconds
()
/
3600
>
exception
[
-
1
]:
exceptionDay
=
0
# calculate the number of days till the end of the exception
else
:
exceptionDay
=
math
.
floor
((
exception
[
-
1
]
-
hoursToEndFirstDay
.
total_seconds
()
/
3600
)
/
24
)
+
1
for
index2
,
default
in
enumerate
(
defaultShiftPattern
[
node
]):
# check if we still are in the first day
if
hoursToEndFirstDay
.
total_seconds
()
/
3600
>
default
[
-
1
]:
defaultDay
=
0
# calculate the number of days till the end of the default shift
if
node_data
.
get
(
'_class'
,
None
)
==
'Dream.Operator'
:
modifiedDefaultDays
=
[]
# the days of the defaultShiftPattern that have been modified according to the exceptionShiftPattern
if
node
in
exceptionShiftPattern
:
for
index1
,
exception
in
enumerate
(
exceptionShiftPattern
[
node
]):
# XXX think of the case where the exception starts one day and finishes the next
# calculate the time difference in hours from the end of the first day to the end of the exception
# check if we are still in the first day
if
hoursToEndFirstDay
.
total_seconds
()
/
3600
>
exception
[
-
1
]:
exceptionDay
=
0
# calculate the number of days till the end of the exception
else
:
defaultDay
=
math
.
floor
((
default
[
-
1
]
-
hoursToEndFirstDay
.
total_seconds
()
/
3600
)
/
24
)
+
1
if
exceptionDay
==
defaultDay
:
# update the defaultShiftPattern of the node (operator or machine)
# if the exception day has not been modified then delete the previous entry and use the first exception that occurs
if
not
exceptionDay
in
modifiedDefaultDays
:
defaultShiftPattern
[
node
][
index2
]
=
exception
# otherwise append it at the end
exceptionDay
=
math
.
floor
((
exception
[
-
1
]
-
hoursToEndFirstDay
.
total_seconds
()
/
3600
)
/
24
)
+
1
for
index2
,
default
in
enumerate
(
defaultShiftPattern
[
node
]):
# check if we still are in the first day
if
hoursToEndFirstDay
.
total_seconds
()
/
3600
>
default
[
-
1
]:
defaultDay
=
0
# calculate the number of days till the end of the default shift
else
:
defaultShiftPattern
[
node
].
append
(
exception
)
modifiedDefaultDays
.
append
(
exceptionDay
)
# the day has been modified, add to the modified days
break
# update the interruptions of the nodes that have a defaultShiftPattern
if
node
in
defaultShiftPattern
:
# sort the shift pattern of every node
defaultShiftPattern
[
node
].
sort
(
key
=
itemgetter
(
0
))
# get the interruptions of the object
interruptions
=
node_data
.
get
(
"interruptions"
,
{})
if
not
interruptions
:
node_data
[
"interruptions"
]
=
{}
node_data
[
"interruptions"
][
"shift"
]
=
{
"shiftPattern"
:
defaultShiftPattern
.
pop
(
node
),
"endUnfinished"
:
0
}
defaultDay
=
math
.
floor
((
default
[
-
1
]
-
hoursToEndFirstDay
.
total_seconds
()
/
3600
)
/
24
)
+
1
if
exceptionDay
==
defaultDay
:
# update the defaultShiftPattern of the node (operator or machine)
# if the exception day has not been modified then delete the previous entry and use the first exception that occurs
if
not
exceptionDay
in
modifiedDefaultDays
:
defaultShiftPattern
[
node
][
index2
]
=
exception
# otherwise append it at the end
else
:
defaultShiftPattern
[
node
].
append
(
exception
)
modifiedDefaultDays
.
append
(
exceptionDay
)
# the day has been modified, add to the modified days
break
# update the interruptions of the nodes that have a defaultShiftPattern
if
node
in
defaultShiftPattern
:
# sort the shift pattern of every node
defaultShiftPattern
[
node
].
sort
(
key
=
itemgetter
(
0
))
# get the interruptions of the object
interruptions
=
node_data
.
get
(
"interruptions"
,
{})
if
not
interruptions
:
node_data
[
"interruptions"
]
=
{}
node_data
[
"interruptions"
][
"shift"
]
=
{
"shiftPattern"
:
defaultShiftPattern
.
pop
(
node
),
"endUnfinished"
:
0
}
return
data
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