aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs
blob: 7f9d0e57dafa5b5c4fd73fa439f9e2f254c982c4 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.BL.Enumerations;

namespace Tango.MachineStudio.Statistics.Models
{
    public class JobRunModel
    {
        public JobRun JobRun { get; set; }

        public Machine Machine { get; set; }

        public User User { get; set; }

        public TimeSpan? UploadDuration { get; set; }

        public TimeSpan? HeatingDuration { get; set; }

        public RmlModel Rml { get; set; }

        public String Gen
        {
            get
            {
                return JobRun.MachineTypeEnum.ToShortName();
            }
        }

        public double ActualStartPosition
        {
            get { return JobRun.MachineTypeEnum == MachineTypes.Eureka ? JobRun.ActualStartPosition * 4 : JobRun.ActualStartPosition; }
        }

        public double ActualEndPosition
        {
            get
            {
                if (JobRun.ActualEndPosition > 0)
                {
                    return JobRun.MachineTypeEnum == MachineTypes.Eureka ? JobRun.ActualEndPosition * 4 : JobRun.ActualEndPosition;
                }
                else
                {
                    return JobRun.MachineTypeEnum == MachineTypes.Eureka ? JobRun.EndPosition * 4 : JobRun.EndPosition;
                }
            }
        }

        public double Distance
        {
            get
            {
                return ActualEndPosition - ActualStartPosition;
            }
        }

        public double LogicalLengthMeters
        {
            get
            {
                return (JobRun.MachineTypeEnum == MachineTypes.Eureka ? JobRun.JobLogicalLength * 4 : JobRun.JobLogicalLength);
            }
        }

        public double ActualLength
        {
            get { return LogicalLengthMeters * JobRun.NumberOfUnits; }
        }

        public void Init()
        {
            if (JobRun.HeatingStartDate != null)
            {
                UploadDuration = JobRun.HeatingStartDate - JobRun.StartDate;
            }

            if (JobRun.ActualStartDate != null && JobRun.HeatingStartDate != null)
            {
                HeatingDuration = JobRun.ActualStartDate - JobRun.HeatingStartDate;
            }

            if (JobRun.MachineTypeEnum == MachineTypes.Eureka)
            {
                JobRun.JobLogicalLength *= 4;
                JobRun.JobLength *= 4;
                JobRun.EndPosition *= 4;
            }
        }
    }
}