Exemplo n.º 1
0
        void m_tmrChkProjStatusChange_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (base.SigngalEquipment == null)
            {
                return;
            }

            if (this.m_currentProjStatus == null)
            {
                return;
            }

            if (this.m_lIsRunning)
            {
                return;
            }

            this.m_lIsRunning = true;

            SignalLightsStatusInfo currentStatusInfo = CopyStatusInfo(this.m_currentProjStatus);//複製當前狀態值

            this.m_currentProjStatus = null;

            try
            {
                if (base.SigngalEquipment.PLCOnline)
                {
                    if (currentStatusInfo != null)
                    {
                        EnmLightStatus statusGreenLight = GetLightStatus(currentStatusInfo.GreenLight.Trim());
                        EnmLightStatus statusYellowLight = GetLightStatus(currentStatusInfo.YellowLight.Trim());
                        EnmLightStatus statusRedLight = GetLightStatus(currentStatusInfo.RedLight.Trim());
                        EnmBuzzerStatus statusBuzzer = GetBuzzerStatus(currentStatusInfo.AlertRing.Trim());

                        base.SigngalEquipment.SetGreenLightStatus(statusGreenLight);
                        base.SigngalEquipment.SetYellowLightStatus(statusYellowLight);
                        base.SigngalEquipment.SetRedLightStatus(statusRedLight);
                        base.SigngalEquipment.SetBuzzerStatus(statusBuzzer);
                    }
                    else
                    {
                        base.SigngalEquipment.SetGreenLightStatus(EnmLightStatus.OFF);
                        base.SigngalEquipment.SetYellowLightStatus(EnmLightStatus.OFF);
                        base.SigngalEquipment.SetRedLightStatus(EnmLightStatus.OFF);
                        base.SigngalEquipment.SetBuzzerStatus(EnmBuzzerStatus.OFF);
                    }
                }
                else
                {
                    this.OnException(mc_ClassName, "m_tmrChkProjStatusChange_Elapsed", "信號燈操作類連接失敗。");
                }
            }
            catch (Exception ex)
            {
                this.OnException(mc_ClassName, "m_tmrChkProjStatusChange_Elapsed", ex.Message);
            }

            this.m_lIsRunning = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化參數
        /// </summary>
        void InitParams()
        {
            this.m_currentProjStatus = null;

            this.m_lIsRunning = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 創建一個初始狀態
        /// </summary>
        /// <returns></returns>
        SignalLightsStatusInfo CreateInitialStatusInfo()
        {
            SignalLightsStatusInfo statusInfo = new SignalLightsStatusInfo();

            statusInfo.AlertRing = "空";
            statusInfo.GreenLight = "長滅";
            statusInfo.RedLight = "長滅";
            statusInfo.YellowLight = "長滅";
            statusInfo.Status = "INITIAL";

            return statusInfo;
        }
Exemplo n.º 4
0
 /// <summary>
 /// 複製一條信號燈設置信息
 /// </summary>
 /// <param name="statusInfo">信號燈設置信息</param>
 /// <returns>複製的信號燈設置信息</returns>
 SignalLightsStatusInfo CopyStatusInfo(SignalLightsStatusInfo statusInfo)
 {
     if (statusInfo == null)
     {
         return null;
     }
     SignalLightsStatusInfo copyStatusInfo = new SignalLightsStatusInfo();
     copyStatusInfo.Status = statusInfo.Status;
     copyStatusInfo.StatusDesc = statusInfo.StatusDesc;
     copyStatusInfo.IntervalTime = statusInfo.IntervalTime;
     copyStatusInfo.DurationTime = statusInfo.DurationTime;
     copyStatusInfo.GreenLight = statusInfo.GreenLight;
     copyStatusInfo.YellowLight = statusInfo.YellowLight;
     copyStatusInfo.RedLight = statusInfo.RedLight;
     copyStatusInfo.AlertRing = statusInfo.AlertRing;
     return copyStatusInfo;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 設置信息燈狀態
        /// </summary>
        /// <param name="projectStatus">工程狀態</param>
        public override void SetSignalStatus(CustEnum.ProjectStatus projectStatus)
        {
            try
            {
                if (base.SignalLightsStatusInfos != null && base.SignalLightsStatusInfos.Count > 0)
                {
                    SignalLightsStatusInfo currentStatusInfo = base.SignalLightsStatusInfos.FirstOrDefault(x => x.Status == projectStatus.ToString());//匹配指定狀態的信號燈配置記錄

                    if (currentStatusInfo != null)
                    {
                        this.m_currentProjStatus = currentStatusInfo;
                    }
                    else
                    {
                        this.m_currentProjStatus = CreateInitialStatusInfo();
                    }
                }
            }
            catch (Exception)
            {

            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 獲取機台資料MachineBaseData
        /// </summary>
        /// <returns></returns>
        public MachineBaseData GetMachineBaseData()
        {
            if (m_ProfileData == null)
            {
                throw new Exception("不存在機台所需要的基本資料!");
            }

            Model.ProfileData profileData = m_ProfileData;

            string dFormat;
            CodeMaster_cmt_Info code;
            List<CodeMaster_cmt_Info> codes;
            MachineBaseData data = new MachineBaseData();
            List<ShiftInformationHistoryRecord> shiftHistory = new List<ShiftInformationHistoryRecord>();
            List<MachineAreaInfo> areaList = new List<MachineAreaInfo>();
            List<MachineInformation> machineList = new List<MachineInformation>();
            List<MachineStaffInfo> machineStaffInfoList = new List<MachineStaffInfo>();
            List<ShiftTypeInfo> shiftTypeInfoList = new List<ShiftTypeInfo>();
            List<ShiftTypeInfo> specialShiftTypeInfoList = new List<ShiftTypeInfo>();
            List<MachineMaintainPlanInfo> maintainPlanList = new List<MachineMaintainPlanInfo>();
            List<MachineMaintainOperationEquipment> maintainOperationEquipmentList = new List<MachineMaintainOperationEquipment>();
            List<MachineMaintainOperation> machineMaintainOperations = new List<MachineMaintainOperation>();
            List<BaseModel> machineMaintainOperationList = new List<BaseModel>();
            List<MachineRepairRequestStructure> machineRepairRequestStructureList = new List<MachineRepairRequestStructure>();

            List<BaseModel> machineRepairRequestItemList = new List<BaseModel>();
            List<BaseModel> machineRepairRequestGradeList = new List<BaseModel>();
            List<BaseModel> departmentList = new List<BaseModel>();

            List<VacationInfo> vacationInfoList = new List<VacationInfo>();
            List<BaseModel> vacationOTReasonList = new List<BaseModel>();
            List<MachineIdleStateName> machineIdleStateNameList = new List<MachineIdleStateName>();
            List<BaseModel> machineStatuList = new List<BaseModel>();
            List<SignalLightsStatusInfo> signalLightsStatusInfoList = new List<SignalLightsStatusInfo>();
            List<DinnerPlanInfo> dinnerPlanInfoList = new List<DinnerPlanInfo>();
            List<BaseModel> plcBaudRateList = new List<BaseModel>();

            data.ShiftHistory = shiftHistory;
            data.MachineAreas = areaList;
            data.MachineInformations = machineList;
            data.MachineStaffInfos = machineStaffInfoList;
            data.ShiftTypeInfos = shiftTypeInfoList;
            data.SpecialShiftTypeInfos = specialShiftTypeInfoList;
            data.MachineMaintainPlanInfos = maintainPlanList;
            data.MachineMaintainOperations = machineMaintainOperationList;
            data.MachineMaintainOperationList = machineMaintainOperations;
            data.MachineRepairRequestStructures = machineRepairRequestStructureList;
            data.MachineRepairRequestItems = machineRepairRequestItemList;
            data.MachineRepairRequestGrades = machineRepairRequestGradeList;
            data.Departments = departmentList;
            data.VacationInfos = vacationInfoList;
            data.VacationOTReasons = vacationOTReasonList;
            data.MachineIdleStateNames = machineIdleStateNameList;
            data.MachineStatus = machineStatuList;
            data.SignalLightsStatusInfos = signalLightsStatusInfoList;
            data.DinnerPlanInfos = dinnerPlanInfoList;
            data.PLCBaudRates = plcBaudRateList;
            data.MachineMaintainOperationEquipments = maintainOperationEquipmentList;

            try
            {
                code = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_SYSTEM, DefineConstantValue.CodeMasterDefine.KEY2_SETTING, DefineConstantValue.CodeMasterDefine.VALUE_DFormat);
                if (code != null)
                {
                    dFormat = code.cmt_cRemark;
                }
                else
                {
                    dFormat = "yyyy/MM/dd";
                }

                //班次歷史記錄列表

                foreach (ShiftInfo_sifo_Info item in profileData.ShiftInfo)
                {
                    ShiftInformationHistoryRecord obj = new ShiftInformationHistoryRecord();
                    obj.Code = item.sifo_RecordID.ToString();
                    obj.Description = item.sifo_dBeginTime.Value.ToString(dFormat);
                    ShiftTypeMaster_stm_Info shiftType = profileData.ShiftTypeMaster.FirstOrDefault(f => f.stm_iRecordID == item.sifo_iSTMID);
                    if (shiftType != null)
                    {
                        obj.Description += " " + shiftType.stm_cShiftName;
                    }
                    if (profileData.ShiftProjList != null && profileData.ShiftProjList.Count > 0)
                    {
                        obj.HistoryShiftProjects = profileData.ShiftProjList.Where(w => w.spl_SIFOID.ToString() == obj.Code)
                            .Select(s => new BaseModel() { Code = s.spl_RecordID.ToString(), Description = "" })
                            .ToList();
                    }
                    shiftHistory.Add(obj);
                }

                //機台區域列表
                foreach (AreaMaster_amr_Info item in profileData.AreaMaster)
                {
                    MachineAreaInfo obj = new MachineAreaInfo()
                    {
                        Code = item.amr_cRecordID.ToString(),
                        Description = item.amr_cAreaName,
                        MachineInformations = profileData.MachineMaster.Where(s => s.mmt_cAreaID == item.amr_cRecordID && s.mmt_iIsPublic == false || s.mmt_iIsPublic == true)
                        .Select(s => new MachineInformation
                        {
                            AreaCode = item.amr_cRecordID.ToString(),
                            Description = s.mmt_cMachineID,
                            Code = s.mmt_cMachineID
                        }).ToList(),
                        MachineStaffInfos = profileData.StaffInfoMaster.Where(w => w.sim_amrID == item.amr_cRecordID)
                        .Select(s => new MachineStaffInfo
                        {
                            AreaCode = s.sim_amrID.ToString(),
                            Code = s.sim_iRecordID.ToString(),
                            Description = s.sim_cStaffName,
                            IsCaptain = s.sim_lIsCaptain
                        }).ToList(),
                    };
                    areaList.Add(obj);
                }

                //機台列表
                foreach (MachineMaster_mmt_Info item in profileData.MachineMaster)
                {
                    MachineInformation obj = new MachineInformation();

                    obj.Code = item.mmt_cMachineID;
                    obj.Description = item.mmt_cMachineID;
                    obj.AreaCode = item.mmt_cAreaID.ToString();
                    obj.MachineType = item.mmt_cMachineType;

                    if (item.mmt_cModel.Trim().Length > 0)
                    {
                        int speed = 0;
                        int.TryParse(item.mmt_cModel, out speed);

                        obj.MachineSpeed = speed;
                    }

                    machineList.Add(obj);
                }
                //機組人員列表
                foreach (StaffInfoMaster_sim_Info item in profileData.StaffInfoMaster)
                {
                    string stattInfoDesc = string.Empty;

                    if (!string.IsNullOrEmpty(item.sim_cStaffName))
                    {
                        stattInfoDesc += item.sim_cStaffName;
                    }

                    if (!string.IsNullOrEmpty(item.sim_cStaffNo))
                    {
                        stattInfoDesc += "(" + item.sim_cStaffNo.Trim() + ")";
                    }

                    MachineStaffInfo obj = new MachineStaffInfo()
                    {
                        AreaCode = item.sim_amrID.ToString(),
                        IsCaptain = item.sim_lIsCaptain,
                        Code = item.sim_iRecordID.ToString(),
                        Description = item.sim_cStaffName,
                        StaffNameNo = stattInfoDesc,
                        StaffNo = item.sim_cStaffNo
                    };
                    machineStaffInfoList.Add(obj);
                }

                //班次類型信息列表
                foreach (ShiftTypeMaster_stm_Info item in profileData.ShiftTypeMaster)
                {
                    if (item != null && item.stm_lIsAtive == true)
                    {
                        ShiftTypeInfo obj = new ShiftTypeInfo()
                        {
                            Code = item.stm_iRecordID.ToString(),
                            BeginTime = item.stm_cBeginTime,
                            EndTime = item.stm_cEndTime,
                            Description = item.stm_cShiftName
                        };
                        shiftTypeInfoList.Add(obj);
                    }
                }

                //特殊班次類型信息列表
                foreach (ShiftTypeMaster_stm_Info item in profileData.SpecialShiftTypeMaster)
                {
                    if (item != null && item.stm_lIsAtive == true)
                    {
                        ShiftTypeInfo obj = new ShiftTypeInfo()
                        {
                            Code = item.stm_iRecordID.ToString(),
                            SpecialShiftDate = item.ShiftDate,
                            BeginTime = item.stm_cBeginTime,
                            EndTime = item.stm_cEndTime,
                            Description = item.stm_cShiftName
                        };
                        specialShiftTypeInfoList.Add(obj);
                    }
                }

                //機台保養計劃設置列表
                foreach (MaintainPlan_mtp_Info item in profileData.MaintainPlanMaster)
                {
                    MachineMaintainPlanInfo obj = new MachineMaintainPlanInfo()
                    {
                        Code = item.mtp_iRecordID.ToString(),
                        BeginDate = item.mtp_dBeginDate,
                        WorkTime = item.mtp_dWorkTime,
                        ExpireTime = item.mtp_dExpireTime,
                        Description = "",
                        DateIndex = item.mtp_cDateIndex,
                        PeriodType = item.mtp_iPeriodType,
                        MaintainOperationID = item.mtp_iMOMID.Value
                    };

                    maintainPlanList.Add(obj);
                }
                //機台保養動作名稱列表
                foreach (MaintainOperationMaster_mom_Info item in profileData.MaintainOperationMaster)
                {
                    BaseModel obj = new BaseModel()
                    {
                        Code = item.mom_iRecordID.ToString(),
                        Description = item.mom_cOperationName,
                    };
                    machineMaintainOperationList.Add(obj);

                    MachineMaintainOperation operation = new MachineMaintainOperation()
                    {
                        Code = item.mom_cOperationCode,
                        RecordID=item.mom_iRecordID,
                        Description = item.mom_cOperationName,
                        OperationType = item.mom_cOperationType,
                        CompleteTime=item.mom_iCompleteTime,
                        StandardFilePath=item.mom_cStandardFilePath,
                    };

                    machineMaintainOperations.Add(operation);
                }

                //保養動作部件列表列表
                if (profileData.MaintainOperationEquipments != null && profileData.MaintainOperationEquipments.Count > 0)
                {
                    foreach (MaintainPlanEquipmentMapping_mpe_Info item in profileData.MaintainOperationEquipments)
                    {
                        if (item != null)
                        {
                            MachineMaintainOperationEquipment obj = new MachineMaintainOperationEquipment()
                            {
                                mpe_cRecordID = item.mpe_cRecordID,
                                mpe_iMOMID = item.mpe_iMOMID,
                                mpe_cEquipmentNum = item.mpe_cEquipmentNum,
                                mpe_cEquipmentName = item.mpe_cEquipmentName,
                                mpe_cPreEquipmentNum = item.mpe_cPreEquipmentNum,
                                mpe_cRootEquipmentNum = item.mpe_cRootEquipmentNum,
                                mpe_cFullName = item.mpe_cFullName,
                                mpe_cFullNum = item.mpe_cFullNum,
                                mpe_dLastDate = item.mpe_dLastDate
                            };
                            maintainOperationEquipmentList.Add(obj);
                        }
                    }
                }

                // 機台維修請求結構列表
                List<StructureMaster_stt_Info> level1 = profileData.StructureMaster.Where(w => w.stt_cKey2 == Guid.Empty && w.stt_cKey3 == Guid.Empty).ToList();
                List<StructureMaster_stt_Info> level2 = profileData.StructureMaster.Where(w => w.stt_cKey1 != Guid.Empty && w.stt_cKey2 != Guid.Empty && w.stt_cKey3 == Guid.Empty).ToList();
                List<StructureMaster_stt_Info> level3 = profileData.StructureMaster.Where(w => w.stt_cKey1 != Guid.Empty && w.stt_cKey2 != Guid.Empty && w.stt_cKey3 != Guid.Empty).ToList();

                foreach (StructureMaster_stt_Info item in level1)
                {
                    MachineRepairRequestStructure obj = new MachineRepairRequestStructure()
                    {
                        Code = item.stt_iRecordID.ToString(),
                        Description = item.stt_cDesc,
                        SubStructures = new List<MachineRepairRequestStructure>()
                    };
                    obj.SubStructures = level2.Where(w => w.stt_cKey1 == item.stt_cKey1)
                            .Select(s => new MachineRepairRequestStructure()
                            {
                                Code = s.stt_iRecordID.ToString(),
                                Description = s.stt_cDesc,
                                SubStructures = new List<MachineRepairRequestStructure>()
                            }).ToList();

                    foreach (MachineRepairRequestStructure lv2 in obj.SubStructures)
                    {
                        StructureMaster_stt_Info sourceLV2 = level2.FirstOrDefault(s => s.stt_iRecordID.ToString() == lv2.Code);
                        if (sourceLV2 != null)
                        {
                            lv2.SubStructures = level3.Where(w => w.stt_cKey1 == sourceLV2.stt_cKey1 && w.stt_cKey2 == sourceLV2.stt_cKey2)
                                   .Select(s => new MachineRepairRequestStructure()
                                   {
                                       Code = s.stt_iRecordID.ToString(),
                                       Description = s.stt_cDesc,
                                       SubStructures = new List<MachineRepairRequestStructure>()
                                   }).ToList();
                        }
                    }
                    machineRepairRequestStructureList.Add(obj);
                }

                //機台維修請求維修項目列表

                codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_PPCFORMITEM, DefineConstantValue.CodeMasterDefine.KEY2_PPCFORMITEM_MAINTENANCEITEM);
                foreach (CodeMaster_cmt_Info item in codes)
                {
                    BaseModel obj = new BaseModel()
                    {
                        Code = item.cmt_cValue,
                        Description = item.cmt_cRemark

                    };
                    machineRepairRequestItemList.Add(obj);
                }

                //機台維修請求維修級別列表

                codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_PPCFORMITEM, DefineConstantValue.CodeMasterDefine.KEY2_PPCFORMITEM_MAINTENANCELEVEL);
                foreach (CodeMaster_cmt_Info item in codes)
                {
                    BaseModel obj = new BaseModel()
                    {
                        Code = item.cmt_cValue,
                        Description = item.cmt_cRemark

                    };
                    machineRepairRequestGradeList.Add(obj);
                }
                //科組列表
                codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_DEPARTMENT);
                foreach (CodeMaster_cmt_Info item in codes)
                {
                    BaseModel obj = new BaseModel()
                    {
                        Code = item.cmt_cValue,
                        Description = item.cmt_cRemark

                    };
                    departmentList.Add(obj);
                }

                //PLC波特率列表
                codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_PLCPARAMETER, DefineConstantValue.CodeMasterDefine.KEY2_PLCPARAMETER_BAUDRATE);
                foreach (CodeMaster_cmt_Info item in codes)
                {
                    if (item != null && item.cmt_cValue.Trim().Length > 0)
                    {
                        BaseModel obj = new BaseModel()
                        {
                            Code = item.cmt_cValue,
                            Description = item.cmt_cValue

                        };
                        plcBaudRateList.Add(obj);
                    }
                }

                //假期管理設置信息列表
                foreach (VacationMaster_vcm_Info item in profileData.VacationMaster)
                {
                    VacationInfo obj = new VacationInfo()
                    {
                        AreaCode = item.vcm_TargetID.ToString(),
                        Code = item.vcm_RecordID.ToString(),
                        WeekDate = item.vcm_cWeekDate,
                        StartDate = item.vcm_dStartDate,
                        EndDate = item.vcm_dEndDate,
                        Type = item.vcm_cType,
                        Description = item.vcm_cHolidayName
                    };
                    vacationInfoList.Add(obj);
                }

                //假期上班原因列表
                codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_VACATIONWORKREASON);
                foreach (CodeMaster_cmt_Info item in codes)
                {
                    BaseModel obj = new BaseModel()
                    {
                        Code = item.cmt_cValue,
                        Description = item.cmt_cRemark

                    };
                    vacationOTReasonList.Add(obj);
                }

                //機台空閒狀態名稱列表
                foreach (IdleState_ism_Info item in profileData.IdleStateMaster)
                {
                    MachineIdleStateName obj = new MachineIdleStateName()
                    {
                        Code = item.ism_RecordID.ToString(),
                        Description = item.ism_cStateName,
                        IsBuildin = item.ism_lIsBuildin
                    };
                    machineIdleStateNameList.Add(obj);
                }

                //機台狀態
                codes = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_STATUS, DefineConstantValue.CodeMasterDefine.KEY2_TYPEVALUE_MACHINE);
                foreach (CodeMaster_cmt_Info item in codes)
                {
                    BaseModel obj = new BaseModel()
                    {
                        Code = item.cmt_cValue,
                        Description = item.cmt_cRemark

                    };
                    machineStatuList.Add(obj);
                }

                //生產信號燈設置信息列表
                foreach (SignalLightsStatus_sls_Info item in profileData.SignalLightsStatusMaster)
                {
                    SignalLightsStatusInfo obj = new SignalLightsStatusInfo()
                    {
                        AlertRing = item.sls_cAlertRing,
                        DurationTime = item.sls_iDurationTime,
                        GreenLight = item.sls_cGreenLight,
                        IntervalTime = item.sls_iIntervalTime,
                        RedLight = item.sls_cRedLight,
                        Status = item.sls_cStatus,
                        YellowLight = item.sls_cYellowLight,
                    };
                    signalLightsStatusInfoList.Add(obj);
                }
                //用餐計劃設置信息列表
                foreach (DinnerScheduleMaster_dsm_Info item in profileData.DinnerMaster)
                {
                    DinnerPlanInfo obj = new DinnerPlanInfo
                    {
                        BeginTime = item.dsm_cBeginTime,
                        Code = item.dsm_RecordID.ToString(),
                        EndTime = item.dsm_cEndTime,
                        Description = item.dsm_cScheduleName
                    };
                    dinnerPlanInfoList.Add(obj);
                }

                //窗口菜單列表
                if (profileData.FormMaster != null)
                {
                    List<Sys_FormMaster_fom_Info> forms = profileData.FormMaster.Where(d => d.fom_cSysCode == CustEnum.System.PPC.ToString() && d.fom_lVaild).ToList();

                    if (forms != null)
                    {
                        data.MenuForms = TreeNodeUtil.CreateMenuTree(forms, 1);
                    }
                }

                //系統支援信息
                code = GetCodeMasters(profileData, DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE, DefineConstantValue.CodeMasterDefine.KEY2_SYSTEMSUPPORTINFORMATION, DefineConstantValue.CodeMasterDefine.VALUE_SYSTEMSUPPORTINFORMATION);
                if (code != null)
                {
                    data.SystemSupportInformation = code.cmt_cRemark;
                }

                return data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }