internal void RaiseProgressEvent(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     if (OnProgress != null)
     {
         OnProgress(this, new ProgressEventArgs(id, text, work, workStatus, workResult));
     }
 }
Beispiel #2
0
        private void EComplete(long count)
        {
            try
            {
                switch (mwst_status)
                {
                case WorkStatusType.STARTING:
                    mwst_status = WorkStatusType.STARTED;
                    break;

                case WorkStatusType.STOPPING:
                    mwst_status = WorkStatusType.STOPPED;
                    break;

                default:
                    break;
                }

                this.Invoke(new Action(() =>
                {
                    pgb_progress.Value = pgb_progress.Minimum;
                    lst_info.Items.Add(string.Format("Tasks({0}) is completed!", count));

                    ShowButtons();
                }));
            }
            catch (TargetInvocationException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        protected uint RaiseProgressEvent(string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
        {
            uint newID = ProgressEventArgs.NewID();

            OnProgress(newID, text, work, workStatus, workResult);
            return(newID);
        }
Beispiel #4
0
 protected virtual void OnProgress(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     if (_rootModel != null)
     {
         _rootModel.RaiseProgressEvent(id, text, work, workStatus, workResult);
     }
 }
 private void init(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     ID         = id;
     Text       = text;
     Work       = work;
     WorkStatus = workStatus;
     WorkResult = workResult;
 }
 private void init(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     ID = id;
     Text = text;
     Work = work;
     WorkStatus = workStatus;
     WorkResult = workResult;
 }
Beispiel #7
0
 private void btn_stop_Click(object sender, EventArgs e)
 {
     pgb_progress.Value = pgb_progress.Minimum;
     if (TaskManager.Instance.IsReady)
     {
         mwt_type    = WorkType.STOP;
         mwst_status = WorkStatusType.STOPPING;
         ShowButtons();
         lst_info.Items.Clear();
         TaskManager.Instance.Stop();
     }
 }
Beispiel #8
0
        /// <summary>
        /// Change the WorkOrder's status, and log an history record for the status change
        /// </summary>
        /// <param name="status">The new status for the WorkOrder</param>
        /// <param name="currentUserRole">The user requesting the status change</param>
        public void ChangeStatusTo(WorkStatusType status, UserRole currentUserRole)
        {
            if (currentUserRole == null)
            {
                return;
            }
            var fromState = Status;

            Status = status;
            var workOrderHistory = WorkOrderHistory.Create(this, fromState, currentUserRole);

            if (workOrderHistory != null)
            {
                WorkOrderHistories.Add(workOrderHistory);
            }
        }
        public static WorkOrderHistory Create(WorkOrder workOrder,
                                              WorkStatusType fromState, UserRole currentUserRole)
        {
            if (workOrder == null)
            {
                return(null);
            }
            if (currentUserRole == null)
            {
                return(null);
            }
            var workOrderHistory = new WorkOrderHistory
            {
                WorkOrderId = workOrder.Id,
                WorkOrder   = workOrder,
                UserRoleId  = currentUserRole.Id,
                UserRole    = currentUserRole,
                FromStatus  = fromState,
                ToStatus    = workOrder.Status
            };

            workOrderHistory.SetAuditInfo(currentUserRole.User.Login);
            return(workOrderHistory);
        }
 protected void RaiseProgressEvent(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     OnProgress(id, text, work, workStatus, workResult);
 }
 protected uint RaiseProgressEvent(string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     uint newID = ProgressEventArgs.NewID();
     OnProgress(newID, text, work, workStatus, workResult);
     return newID;
 }
Beispiel #12
0
 /// <summary>
 /// Updates properties of the status with a single call.
 /// </summary>
 public void Update(double?progress, WorkStatusType type)
 {
     Progress = progress;
     Type     = type;
 }
 protected virtual void OnProgress(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     if (_rootModel != null)
         _rootModel.RaiseProgressEvent(id, text, work, workStatus, workResult);
 }
Beispiel #14
0
 public WorkStatus(double?progress, string description, WorkStatusType type = WorkStatusType.Other)
 {
     Update(progress, description, type);
 }
Beispiel #15
0
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
        #endregion

        #region Methods
        /// <summary>
        /// Updates properties of the status with a single call.
        /// </summary>
        public void Update(double?progress, string description, WorkStatusType type = WorkStatusType.Other)
        {
            Progress    = progress;
            Description = description;
            Type        = type;
        }
 public ProgressEventArgs(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     init(id, text, work, workStatus, workResult);
 }
 public ProgressEventArgs(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     init(id, text, work, workStatus, workResult);
 }
Beispiel #18
0
 public ProgressRoutedEventArgs(RoutedEvent routedEvent, object source,
                                uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
     : base(routedEvent, source)
 {
     init(id, text, work, workStatus, workResult);
 }
Beispiel #19
0
 protected void RaiseProgressEvent(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     OnProgress(id, text, work, workStatus, workResult);
 }
        /// <summary>
        /// 绘制一个串口的发送卡
        /// </summary>
        /// <param name="drawX">绘制的X</param>
        /// <param name="drawY">绘制的Y</param>
        /// <param name="commPort">串口名称</param>
        /// <param name="drawGraphics">绘制Graphics</param>
        private void DrawOneCommPortSender(int drawX, int drawY, string commPort, Graphics drawGraphics)
        {
            if (_curAllSenderStatusDic == null ||
                !_curAllSenderStatusDic.ContainsKey(commPort) ||
                _curAllSenderStatusDic[commPort] == null ||
                _curAllSenderStatusDic[commPort].Count <= 0)
            {
                return;
            }
            Point lineStart = Point.Empty;
            Point lineEnd   = Point.Empty;

            drawGraphics.DrawImage(Properties.Resources.CommPort, drawX, drawY, OneCommPortInfoImagePixel, OneCommPortInfoImagePixel);

            lineStart.X = drawX + OneCommPortInfoImagePixel;
            lineStart.Y = drawY + OneCommPortInfoImagePixel / 2;
            lineEnd.X   = lineStart.X + CommPortLineLength;
            lineEnd.Y   = lineStart.Y;
            drawGraphics.DrawLine(CommPortLinePen, lineStart, lineEnd);

            SizeF stringSizeF = drawGraphics.MeasureString(commPort, _commPortFont);

            drawGraphics.DrawString(commPort, _commPortFont, CommPortStrBrush, new PointF(lineStart.X, lineStart.Y - stringSizeF.Height));

            Rectangle senderRect = new Rectangle(lineEnd.X, drawY + SenderSizeOffset / 2,
                                                 OneCommPortInfoImagePixel - SenderSizeOffset,
                                                 OneCommPortInfoImagePixel - SenderSizeOffset);

            int               senderCnt = _curAllSenderStatusDic[commPort].Count;
            string            indexStr  = "";
            PointF            strPointF;
            SenderInfo        senderGridInfo     = null;
            List <SenderInfo> senderGridInfoList = new List <SenderInfo>();
            WorkStatusType    status             = WorkStatusType.Unknown;
            ValueInfo         tempRefreshReate;

            for (byte i = 0; i < senderCnt; i++)
            {
                if (i > 0)
                {
                    senderRect.X += SenderConnectLineLength + OneCommPortInfoImagePixel - SenderSizeOffset;
                }
                status = _curAllSenderStatusDic[commPort][i];
                if (status == WorkStatusType.OK)
                {
                    SenderBrush = new SolidBrush(Color.Green);
                }
                else if (status == WorkStatusType.Error)
                {
                    SenderBrush = new SolidBrush(Color.Yellow);
                }
                else if (status == WorkStatusType.SenderCardError)
                {
                    SenderBrush = new SolidBrush(Color.DarkOrange);
                }
                else
                {
                    SenderBrush = new SolidBrush(Color.Gray);
                }
                tempRefreshReate = new ValueInfo();
                if (_curAllSenderRefreshDic == null ||
                    !_curAllSenderRefreshDic.ContainsKey(commPort) ||
                    _curAllSenderRefreshDic[commPort] == null ||
                    i >= _curAllSenderRefreshDic[commPort].Count)
                {
                    tempRefreshReate.IsValid = false;
                }
                else
                {
                    tempRefreshReate.IsValid = _curAllSenderRefreshDic[commPort][i].IsValid;
                    tempRefreshReate.Value   = _curAllSenderRefreshDic[commPort][i].Value;
                }
                drawGraphics.FillRectangle(SenderBrush, senderRect);
                drawGraphics.DrawRectangle(SenderBoarderAndLinePen, senderRect);

                indexStr    = (i + 1).ToString();
                stringSizeF = drawGraphics.MeasureString(indexStr, _senderStrFont);

                strPointF = new PointF(senderRect.X + (senderRect.Width - stringSizeF.Width) / 2,
                                       senderRect.Y + (senderRect.Height - stringSizeF.Height) / 2);
                drawGraphics.DrawString(indexStr, _senderStrFont, SenderIndexBrush, strPointF);
                RedundantStateType rState = RedundantStateType.Unknown;
                float weightCount         = senderRect.Width;
                if (_commPortData.ContainsKey(commPort) && _commPortData[commPort] > 0)
                {
                    weightCount = senderRect.Width / (float)_commPortData[commPort];
                }
                float    heightCount = (float)senderRect.Width / 4 * 3;
                PointF   newPoint    = senderRect.Location;
                PointF   startPoint  = new PointF(0, 0);
                PointF   endPoint    = new PointF(0, 0);
                PointF[] pointList   = new PointF[4];
                int      step        = 0;

                int masterSender = SenderConnectLineLength + OneCommPortInfoImagePixel - SenderSizeOffset;
                if (_tempRedundancyDict != null && _tempRedundancyDict.ContainsKey(commPort) &&
                    _tempRedundancyDict[commPort] != null &&
                    _commPortData.ContainsKey(commPort) && _redundantStateType.ContainsKey(commPort) &&
                    _redundantStateType[commPort] != null && _redundantStateType[commPort].Count > 0)
                {
                    for (int j = 0; j < _commPortData[commPort]; j++)
                    {
                        if (j >= _redundantStateType[commPort][i].RedundantStateTypeList.Count)
                        {
                            rState = RedundantStateType.Unknown;
                        }
                        else
                        {
                            rState = _redundantStateType[commPort][i].RedundantStateTypeList[j];
                        }
                        if (rState == RedundantStateType.OK)
                        {
                            SenderBrush        = new SolidBrush(Color.Green);
                            CommPortLine.Color = Color.Green;
                            step += 4;
                        }
                        else if (rState == RedundantStateType.Error)
                        {
                            CommPortLine.Color = Color.Red;
                            if (_tempRedundancyDict.ContainsKey(commPort))
                            {
                                for (int k = 0; k < _tempRedundancyDict[commPort].Count; k++)
                                {
                                    SenderRedundancyInfo senderInfo = _tempRedundancyDict[commPort][k];
                                    if (senderInfo.SlaveSenderIndex == i && senderInfo.SlavePortIndex == j)
                                    {
                                        SenderBrush = new SolidBrush(Color.Yellow);
                                        break;
                                    }
                                    else
                                    {
                                        SenderBrush = new SolidBrush(Color.Green);
                                    }
                                }
                            }
                            step += 4;
                        }
                        else
                        {
                            CommPortLine.Color = Color.Gray;
                            SenderBrush        = new SolidBrush(Color.Gray);
                            step += 4;
                        }
                        RectangleF portRect = new RectangleF(newPoint.X + weightCount * j, newPoint.Y + heightCount, weightCount, senderRect.Height / 4);

                        drawGraphics.FillRectangle(SenderBrush, portRect);
                        if (_tempRedundancyDict.ContainsKey(commPort))
                        {
                            for (int k = 0; k < _tempRedundancyDict[commPort].Count; k++)
                            {
                                SenderRedundancyInfo senderInfo = _tempRedundancyDict[commPort][k];
                                if (senderInfo.SlaveSenderIndex == i && senderInfo.SlavePortIndex == j)
                                {
                                    pointList[0] = new PointF(newPoint.X + weightCount * j + weightCount / 2, newPoint.Y + senderRect.Height);
                                    pointList[1] = new PointF(newPoint.X + weightCount * j + weightCount / 2, newPoint.Y + senderRect.Height + step);
                                    if (senderInfo.MasterSenderIndex > senderInfo.SlaveSenderIndex)
                                    {
                                        pointList[2] = new PointF(newPoint.X + masterSender + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height + step);
                                        pointList[3] = new PointF(newPoint.X + masterSender + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height);
                                    }
                                    else if (senderInfo.MasterSenderIndex < senderInfo.SlaveSenderIndex)
                                    {
                                        pointList[2] = new PointF(newPoint.X - masterSender + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height + step);
                                        pointList[3] = new PointF(newPoint.X - masterSender + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height);
                                    }
                                    else
                                    {
                                        pointList[2] = new PointF(newPoint.X + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height + step);
                                        pointList[3] = new PointF(newPoint.X + weightCount * senderInfo.MasterPortIndex + weightCount / 2, newPoint.Y + senderRect.Height);
                                    }
                                    drawGraphics.DrawLines(CommPortLine, pointList);

                                    if (rState == RedundantStateType.Error)
                                    {
                                        PointF centerPoint = new PointF(pointList[2].X + (pointList[1].X - pointList[2].X) / 2, pointList[1].Y);
                                        startPoint = new PointF(centerPoint.X - 4, centerPoint.Y - 4);
                                        endPoint   = new PointF(centerPoint.X + 4, centerPoint.Y + 4);
                                        drawGraphics.DrawLine(CommPortLine, startPoint, endPoint);

                                        startPoint = new PointF(centerPoint.X - 4, centerPoint.Y + 4);
                                        endPoint   = new PointF(centerPoint.X + 4, centerPoint.Y - 4);
                                        drawGraphics.DrawLine(CommPortLine, startPoint, endPoint);
                                    }

                                    break;
                                }
                            }
                        }
                    }
                    CommPortLine.Color = Color.Black;
                    for (int j = 1; j < _commPortData[commPort]; j++)
                    {
                        startPoint = new PointF(newPoint.X + weightCount * j, newPoint.Y + heightCount);
                        endPoint   = new PointF(newPoint.X + weightCount * j, newPoint.Y + senderRect.Height);
                        drawGraphics.DrawLine(CommPortLine, startPoint, endPoint);
                    }

                    startPoint = new PointF(newPoint.X, newPoint.Y + heightCount);
                    endPoint   = new PointF(newPoint.X + senderRect.Width, newPoint.Y + heightCount);
                    drawGraphics.DrawLine(CommPortLine, startPoint, endPoint);
                }
                if (i < senderCnt - 1)
                {
                    lineStart.X = senderRect.Right;
                    lineStart.Y = drawY + OneCommPortInfoImagePixel / 2;

                    lineEnd.X = senderRect.Right + SenderConnectLineLength;
                    lineEnd.Y = lineStart.Y;

                    drawGraphics.DrawLine(SenderBoarderAndLinePen, lineStart, lineEnd);
                }
                senderGridInfo                 = new SenderInfo();
                senderGridInfo.CommPort        = commPort;
                senderGridInfo.SenderIndex     = i;
                senderGridInfo.SenderRect      = senderRect;
                senderGridInfo.Status          = status;
                senderGridInfo.RefreshRateInfo = tempRefreshReate;
                if (_commPortData.ContainsKey(commPort) && _redundantStateType.ContainsKey(commPort) &&
                    i < _redundantStateType[commPort].Count)
                {
                    for (int j = 0; j < _commPortData[commPort]; j++)
                    {
                        if (j < _redundantStateType[commPort][i].RedundantStateTypeList.Count)
                        {
                            senderGridInfo.RedundantStateTypeList.Add(j, _redundantStateType[commPort][i].RedundantStateTypeList[j]);
                        }
                    }
                }
                senderGridInfoList.Add(senderGridInfo);
            }
            _curAllSenderGridDic.Add(commPort, senderGridInfoList);
        }
 internal void RaiseProgressEvent(uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
 {
     if (OnProgress != null)
         OnProgress(this, new ProgressEventArgs(id, text, work, workStatus, workResult));
 }
 public ProgressRoutedEventArgs(RoutedEvent routedEvent, object source,
     uint id, string text, WorkType work, WorkStatusType workStatus, WorkResultType workResult)
     : base(routedEvent, source)
 {
     init(id, text, work, workStatus, workResult);
 }