Skip to content

Commit f3c48fc

Browse files
committed
updated the README.md
1 parent b2b7d67 commit f3c48fc

File tree

1 file changed

+230
-2
lines changed

1 file changed

+230
-2
lines changed

README.md

Lines changed: 230 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,230 @@
1-
# ShiftSharp
2-
C# port of java Shift project
1+
# Shift
2+
The Shift library project manages work schedules. A work schedule consists of one or more teams who rotate through a sequence of shift and off-shift periods of time. The Shift project allows breaks during shifts to be defined as well as non-working periods of time (e.g. holidays and scheduled maintenance periods) that are applicable to the entire work schedule. The C# project is a port of the java project at https://github.com/point85/Shift.
3+
4+
## Concepts
5+
6+
The diagram below illustrates Business Management Systems' DNO (Day, Night, Off) work schedule with three teams and two 12-hour shifts with a 3-day rotation. This schedule is explained in http://community.bmscentral.com/learnss/ZC/3T/c3tr12-1.
7+
8+
![Work Schedule Diagram](https://github.com/point85/shift/blob/master/doc/DNO.png)
9+
10+
*Shift*
11+
12+
A shift is defined with a name, description, starting time of day and duration. An off-shift period is associated with a shift. In the example above for Team1, there are two shifts followed by one off-shift period. Shifts can be overlapped (typically when a handoff of duties is important such as in the nursing profession). A rotation is a sequence of shifts and off-shift days. The DNO rotation is Day on, Night on and Night off. An instance of a shift has a starting date and time of day and has an associated shift definition.
13+
14+
*Team*
15+
16+
A team is defined with a name and description. It has a rotation with a starting date. The starting date shift will have an instance with that date and a starting time of day as defined by the shift. The same rotation can be shared between more than one team, but with different starting times.
17+
18+
*Work Schedule*
19+
20+
A work schedule is defined with a name and description. It has one or more teams. Zero or more non-working periods can be defined. A non-working period has a defined starting date and time of day and duration. For example, the New Year's Day holiday starting at midnight for 24 hours, or three consecutive days for preventive maintenance of manufacturing equipment starting at the end of the night shift.
21+
22+
After a work schedule is defined, the working time for all shifts can be computed for a defined time interval. For example, this duration of time is the maximum available productive time as an input to the calculation of the utilization of equipment in a metric known as the Overall Equipment Effectiveness (OEE).
23+
24+
*Rotation*
25+
26+
A rotation is a sequence of working periods (segments). Each segment starts with a shift and specifies the number of days on-shift and off-shift. A work schedule can have more than one rotation.
27+
28+
*Non-Working Period*
29+
30+
A non-working period is a duration of time where no teams are working. For example, a holiday or a period of time when a plant is shutdown for preventative maintenance. A non-working period starts at a defined day and time of day and continues for the specified duration of time.
31+
32+
*Shift Instance*
33+
34+
A shift instance is the duration of time from a specified date and time of day and continues for the duration of the associated shift. A team works this shift instance.
35+
36+
## Examples
37+
The DNO schedule discussed above is defined as follows.
38+
39+
```cs
40+
String description = "This is a fast rotation plan that uses 3 teams and two 12-hr shifts to provide 24/7 coverage. "
41+
+ "Each team rotates through the following sequence every three days: 1 day shift, 1 night shift, and 1 day off.";
42+
43+
WorkSchedule schedule = new WorkSchedule("DNO Plan", description);
44+
45+
// Day shift, starts at 07:00 for 12 hours
46+
Shift day = schedule.CreateShift("Day", "Day shift", new LocalTime(7, 0, 0), Duration.FromHours(12));
47+
48+
// Night shift, starts at 19:00 for 12 hours
49+
Shift night = schedule.CreateShift("Night", "Night shift", new LocalTime(19, 0, 0), Duration.FromHours(12));
50+
51+
// rotation
52+
Rotation rotation = new Rotation("DNO", "DNO");
53+
rotation.AddSegment(day, 1, 0);
54+
rotation.AddSegment(night, 1, 1);
55+
56+
schedule.CreateTeam("Team 1", "First team", rotation, referenceDate);
57+
schedule.CreateTeam("Team 2", "Second team", rotation, referenceDate.Minus(Period.FromDays(1)));
58+
schedule.CreateTeam("Team 3", "Third team", rotation, referenceDate.Minus(Period.FromDays(2)));
59+
```
60+
To obtain the working time over three days starting at 07:00, the following methods are called:
61+
62+
```cs
63+
LocalDateTime from = referenceDate.At(new LocalTime(7, 0, 0));
64+
Duration duration = schedule.CalculateWorkingTime(from, from.PlusDays(3));
65+
```
66+
67+
To obtain the shift instances for a date, the following method is called:
68+
69+
```cs
70+
List<ShiftInstance> instances = schedule.GetShiftInstancesForDay(new LocalDate(2017, 3, 1));
71+
```
72+
73+
To print a work schedule, call the ToString() method. For example:
74+
75+
```cs
76+
Schedule: DNO Plan (This is a fast rotation plan that uses 3 teams and two 12-hr shifts to provide 24/7 coverage. Each team rotates through the following sequence every three days: 1 day shift, 1 night shift, and 1 day off.)
77+
Rotation duration: PT216H, Scheduled working time: PT72H
78+
Shifts:
79+
(1) Day (Day shift), Start : 07:00 (PT12H), End : 19:00
80+
(2) Night (Night shift), Start : 19:00 (PT12H), End : 07:00
81+
Teams:
82+
(1) Team 1 (First team), Rotation start: 2016-10-31, Rotation periods: [Day (on), Night (on), (off) ], Rotation duration: PT72H, Days in rotation: 3, Scheduled working time: PT24H, Percentage worked: 33.33%, Average hours worked per week: PT56H
83+
(2) Team 2 (Second team), Rotation start: 2016-10-30, Rotation periods: [Day (on), Night (on),(off) ], Rotation duration: PT72H, Days in rotation: 3, Scheduled working time: PT24H, Percentage worked: 33.33%, Average hours worked per week: PT56H
84+
(3) Team 3 (Third team), Rotation start: 2016-10-29, Rotation periods: [Day (on), Night (on), (off) ], Rotation duration: PT72H, Days in rotation: 3, Scheduled working time: PT24H, Percentage worked: 33.33%, Average hours worked per week: PT56H
85+
Total team coverage: 100%
86+
```
87+
88+
To print shift instances between two dates, the following method is called:
89+
90+
```cs
91+
schedule.PrintShiftInstances(new LocalDate(2016, 10, 31), new LocalDate(2016, 11, 3));
92+
```
93+
with output:
94+
95+
```cs
96+
Working shifts
97+
[1] Day: 2016-10-31
98+
(1) Team: Team 1, Shift: Day, Start : 2016-10-31T07:00, End : 2016-10-31T19:00
99+
(2) Team: Team 2, Shift: Night, Start : 2016-10-31T19:00, End : 2016-11-01T07:00
100+
[2] Day: 2016-11-01
101+
(1) Team: Team 3, Shift: Day, Start : 2016-11-01T07:00, End : 2016-11-01T19:00
102+
(2) Team: Team 1, Shift: Night, Start : 2016-11-01T19:00, End : 2016-11-02T07:00
103+
[3] Day: 2016-11-02
104+
(1) Team: Team 2, Shift: Day, Start : 2016-11-02T07:00, End : 2016-11-02T19:00
105+
(2) Team: Team 3, Shift: Night, Start : 2016-11-02T19:00, End : 2016-11-03T07:00
106+
[4] Day: 2016-11-03
107+
(1) Team: Team 1, Shift: Day, Start : 2016-11-03T07:00, End : 2016-11-03T19:00
108+
(2) Team: Team 2, Shift: Night, Start : 2016-11-03T19:00, End : 2016-11-04T07:00
109+
```
110+
111+
For a second example, the 24/7 schedule below has two rotations for four teams in two shifts. It is used by manufacturing companies.
112+
113+
```cs
114+
WorkSchedule schedule = new WorkSchedule("Manufacturing Company - four twelves",
115+
"Four 12 hour alternating day/night shifts");
116+
117+
// day shift, start at 07:00 for 12 hours
118+
Shift day = schedule.CreateShift("Day", "Day shift", new LocalTime(7, 0, 0), Duration.FromHours(12));
119+
120+
// night shift, start at 19:00 for 12 hours
121+
Shift night = schedule.CreateShift("Night", "Night shift", new LocalTime(19, 0, 0), Duration.FromHours(12));
122+
123+
// 7 days ON, 7 OFF
124+
Rotation dayRotation = new Rotation("Day", "Day");
125+
dayRotation.AddSegment(day, 7, 7);
126+
127+
// 7 nights ON, 7 OFF
128+
Rotation nightRotation = new Rotation("Night", "Night");
129+
nightRotation.AddSegment(night, 7, 7);
130+
131+
schedule.CreateTeam("A", "A day shift", dayRotation, new LocalDate(2014, 1, 2));
132+
schedule.CreateTeam("B", "B night shift", nightRotation, new LocalDate(2014, 1, 2));
133+
schedule.CreateTeam("C", "C day shift", dayRotation, new LocalDate(2014, 1, 9));
134+
schedule.CreateTeam("D", "D night shift", nightRotation, new LocalDate(2014, 1, 9));
135+
```
136+
137+
When printed out for a week of shift instances, the output is:
138+
139+
```cs
140+
Schedule: Manufacturing Company - four twelves (Four 12 hour alternating day/night shifts)
141+
Rotation duration: PT1344H, Scheduled working time: PT336H
142+
Shifts:
143+
(1) Day (Day shift), Start : 07:00 (PT12H), End : 19:00
144+
(2) Night (Night shift), Start : 19:00 (PT12H), End : 07:00
145+
Teams:
146+
(1) A (A day shift), Rotation start: 2014-01-02, Rotation periods: [Day (on), Day (on), Day (on), Day (on), Day (on), Day (on), Day (on), (off), (off), (off), (off), (off), (off), (off) ], Rotation duration: PT336H, Days in rotation: 14, Scheduled working time: PT84H, Percentage worked: 25%, Average hours worked per week: PT42H
147+
(2) B (B night shift), Rotation start: 2014-01-02, Rotation periods: [Night (on), Night (on), Night (on), Night (on), Night (on), Night (on), Night (on), (off), (off), (off), (off), (off), (off), (off) ], Rotation duration: PT336H, Days in rotation: 14, Scheduled working time: PT84H, Percentage worked: 25%, Average hours worked per week: PT42H
148+
(3) C (C day shift), Rotation start: 2014-01-09, Rotation periods: [Day (on), Day (on), Day (on), Day (on), Day (on), Day (on), Day (on), (off), (off), (off), (off), (off), (off), (off) ], Rotation duration: PT336H, Days in rotation: 14, Scheduled working time: PT84H, Percentage worked: 25%, Average hours worked per week: PT42H
149+
(4) D (D night shift), Rotation start: 2014-01-09, Rotation periods: [Night (on), Night (on), Night (on), Night (on), Night (on), Night (on), Night (on), (off), (off), (off), (off), (off), (off), (off) ], Rotation duration: PT336H, Days in rotation: 14, Scheduled working time: PT84H, Percentage worked: 25%, Average hours worked per week: PT42H
150+
Total team coverage: 100%
151+
Working shifts
152+
[1] Day: 2014-01-09
153+
(1) Team: C, Shift: Day, Start : 2014-01-09T07:00, End : 2014-01-09T19:00
154+
(2) Team: D, Shift: Night, Start : 2014-01-09T19:00, End : 2014-01-10T07:00
155+
[2] Day: 2014-01-10
156+
(1) Team: C, Shift: Day, Start : 2014-01-10T07:00, End : 2014-01-10T19:00
157+
(2) Team: D, Shift: Night, Start : 2014-01-10T19:00, End : 2014-01-11T07:00
158+
[3] Day: 2014-01-11
159+
(1) Team: C, Shift: Day, Start : 2014-01-11T07:00, End : 2014-01-11T19:00
160+
(2) Team: D, Shift: Night, Start : 2014-01-11T19:00, End : 2014-01-12T07:00
161+
[4] Day: 2014-01-12
162+
(1) Team: C, Shift: Day, Start : 2014-01-12T07:00, End : 2014-01-12T19:00
163+
(2) Team: D, Shift: Night, Start : 2014-01-12T19:00, End : 2014-01-13T07:00
164+
[5] Day: 2014-01-13
165+
(1) Team: C, Shift: Day, Start : 2014-01-13T07:00, End : 2014-01-13T19:00
166+
(2) Team: D, Shift: Night, Start : 2014-01-13T19:00, End : 2014-01-14T07:00
167+
[6] Day: 2014-01-14
168+
(1) Team: C, Shift: Day, Start : 2014-01-14T07:00, End : 2014-01-14T19:00
169+
(2) Team: D, Shift: Night, Start : 2014-01-14T19:00, End : 2014-01-15T07:00
170+
[7] Day: 2014-01-15
171+
(1) Team: C, Shift: Day, Start : 2014-01-15T07:00, End : 2014-01-15T19:00
172+
(2) Team: D, Shift: Night, Start : 2014-01-15T19:00, End : 2014-01-16T07:00
173+
```
174+
175+
For a third example, the work schedule below with one 24 hour shift over an 18 day rotation for three platoons is used by Kern County California firefighters.
176+
177+
```cs
178+
WorkSchedule schedule = new WorkSchedule("Kern Co.", "Three 24 hour alternating shifts");
179+
180+
// shift, start 07:00 for 24 hours
181+
Shift shift = schedule.CreateShift("24 Hour", "24 hour shift", new LocalTime(7, 0, 0), Duration.FromHours(24));
182+
183+
// 2 days ON, 2 OFF, 2 ON, 2 OFF, 2 ON, 8 OFF
184+
Rotation rotation = new Rotation("24 Hour", "2 days ON, 2 OFF, 2 ON, 2 OFF, 2 ON, 8 OFF");
185+
rotation.AddSegment(shift, 2, 2);
186+
rotation.AddSegment(shift, 2, 2);
187+
rotation.AddSegment(shift, 2, 8);
188+
189+
Team platoon1 = schedule.CreateTeam("Red", "A Shift", rotation, new LocalDate(2017, 1, 8));
190+
Team platoon2 = schedule.CreateTeam("Black", "B Shift", rotation, new LocalDate(2017, 2, 1));
191+
Team platoon3 = schedule.CreateTeam("Green", "C Shift", rotation, new LocalDate(2017, 1, 2));
192+
```
193+
194+
When printed out for a week of shift instances, the output is:
195+
```cs
196+
Schedule: Kern Co. (Three 24 hour alternating shifts)
197+
Rotation duration: PT1296H, Scheduled working time: PT432H
198+
Shifts:
199+
(1) 24 Hour (24 hour shift), Start : 07:00 (PT24H), End : 07:00
200+
Teams:
201+
(1) Red (A Shift), Rotation start: 2017-01-08, Rotation periods: [24 Hour (on), 24 Hour (on), (off), (off), 24 Hour (on), 24 Hour (on), (off), (off), 24 Hour (on), 24 Hour (on), (off), (off), (off), (off), (off), (off), (off), (off) ], Rotation duration: PT432H, Days in rotation: 18, Scheduled working time: PT144H, Percentage worked: 33.33%, Average hours worked per week: PT56H
202+
(2) Black (B Shift), Rotation start: 2017-02-01, Rotation periods: [24 Hour (on), 24 Hour (on), (off), (off), 24 Hour (on), 24 Hour (on), (off), (off), 24 Hour (on), 24 Hour (on), (off), (off), (off), (off), (off), (off), (off), (off) ], Rotation duration: PT432H, Days in rotation: 18, Scheduled working time: PT144H, Percentage worked: 33.33%, Average hours worked per week: PT56H
203+
(3) Green (C Shift), Rotation start: 2017-01-02, Rotation periods: [24 Hour (on), 24 Hour (on), (off), (off), 24 Hour (on), 24 Hour (on), (off), (off), 24 Hour (on), 24 Hour (on), (off), (off), (off), (off), (off), (off), (off), (off) ], Rotation duration: PT432H, Days in rotation: 18, Scheduled working time: PT144H, Percentage worked: 33.33%, Average hours worked per week: PT56H
204+
Total team coverage: 100%
205+
Working shifts
206+
[1] Day: 2017-02-01
207+
(1) Team: Black, Shift: 24 Hour, Start : 2017-02-01T07:00, End : 2017-02-02T07:00
208+
[2] Day: 2017-02-02
209+
(1) Team: Black, Shift: 24 Hour, Start : 2017-02-02T07:00, End : 2017-02-03T07:00
210+
[3] Day: 2017-02-03
211+
(1) Team: Red, Shift: 24 Hour, Start : 2017-02-03T07:00, End : 2017-02-04T07:00
212+
[4] Day: 2017-02-04
213+
(1) Team: Red, Shift: 24 Hour, Start : 2017-02-04T07:00, End : 2017-02-05T07:00
214+
[5] Day: 2017-02-05
215+
(1) Team: Black, Shift: 24 Hour, Start : 2017-02-05T07:00, End : 2017-02-06T07:00
216+
[6] Day: 2017-02-06
217+
(1) Team: Black, Shift: 24 Hour, Start : 2017-02-06T07:00, End : 2017-02-07T07:00
218+
[7] Day: 2017-02-07
219+
(1) Team: Green, Shift: 24 Hour, Start : 2017-02-07T07:00, End : 2017-02-08T07:00
220+
```
221+
222+
## Project Structure
223+
ShiftSharp depends upon .Net Framework 4.5+ due to use of the NodaTime date and time classes.
224+
225+
ShiftSharp, has the following structure:
226+
* `/Documentation/html` Doxygen HTML files
227+
* `/bin/Release` compiled ShiftSharp.dll
228+
* `.` - C# source files
229+
* `/Resources` - localizable Message.properties file to define error messages.
230+
* `../TestShiftSharp` - unit test C# project

0 commit comments

Comments
 (0)