public TransitionThread(HoldPattern parent) { _parent = parent; _shutdown = new AutoResetEvent(false); _newSchedules = new AutoResetEvent(false); _thread = new Thread(new ThreadStart(ThreadFunc)); _thread.Start(); }
public MazakSchedule(HoldPattern parent, MazakScheduleRow s) { _parent = parent; _schRow = s; if (MazakPart.IsSailPart(_schRow.PartName)) { MazakPart.ParseComment(_schRow.Comment, out string unique, out var paths, out var manual); var job = parent.jobDB.LoadJob(unique); if (job != null) { HoldEntireJob = job.HoldEntireJob; HoldMachining = job.HoldMachining(process: 1, path: paths.PathForProc(proc: 1)); } } }
private static void SchedulePart( MazakWriteData transSet, int SchID, string mazakPartName, string mazakComment, int numProcess, JobPlan part, int proc1path, int earlierConflicts, bool UseStartingOffsetForDueDate) { var newSchRow = new MazakScheduleRow(); newSchRow.Command = MazakWriteCommand.Add; newSchRow.Id = SchID; newSchRow.PartName = mazakPartName; newSchRow.PlanQuantity = part.GetPlannedCyclesOnFirstProcess(proc1path); newSchRow.CompleteQuantity = 0; newSchRow.FixForMachine = 0; newSchRow.MissingFixture = 0; newSchRow.MissingProgram = 0; newSchRow.MissingTool = 0; newSchRow.MixScheduleID = 0; newSchRow.ProcessingPriority = 0; newSchRow.Comment = mazakComment; if (UseStartingOffsetForDueDate) { if (part.GetSimulatedStartingTimeUTC(1, proc1path) != DateTime.MinValue) { var start = part.GetSimulatedStartingTimeUTC(1, proc1path); newSchRow.DueDate = start.ToLocalTime().Date; newSchRow.Priority = 91 + Math.Min(earlierConflicts, 9); } else { newSchRow.DueDate = DateTime.Today; newSchRow.Priority = 91; } } else { newSchRow.Priority = 75; newSchRow.DueDate = DateTime.Parse("1/1/2008 12:00:00 AM"); } bool entireHold = false; if (part.HoldEntireJob != null) { entireHold = part.HoldEntireJob.IsJobOnHold; } bool machiningHold = false; if (part.HoldMachining(1, proc1path) != null) { machiningHold = part.HoldMachining(1, proc1path).IsJobOnHold; } newSchRow.HoldMode = (int)HoldPattern.CalculateHoldMode(entireHold, machiningHold); int matQty = newSchRow.PlanQuantity; if (!string.IsNullOrEmpty(part.GetInputQueue(process: 1, path: proc1path))) { matQty = 0; } //need to add all the ScheduleProcess rows for (int i = 1; i <= numProcess; i++) { var newSchProcRow = new MazakScheduleProcessRow(); newSchProcRow.MazakScheduleRowId = SchID; newSchProcRow.ProcessNumber = i; if (i == 1) { newSchProcRow.ProcessMaterialQuantity = matQty; } else { newSchProcRow.ProcessMaterialQuantity = 0; } newSchProcRow.ProcessBadQuantity = 0; newSchProcRow.ProcessExecuteQuantity = 0; newSchProcRow.ProcessMachine = 0; newSchRow.Processes.Add(newSchProcRow); } transSet.Schedules.Add(newSchRow); }
public MazakBackend(IConfiguration configuration, FMSSettings st) { var cfg = configuration.GetSection("Mazak"); string localDbPath = cfg.GetValue <string>("Database Path"); MazakType = DetectMazakType(cfg, localDbPath); // database settings string sqlConnectString = cfg.GetValue <string>("SQL ConnectionString"); string dbConnStr; if (MazakType == MazakDbType.MazakSmooth) { if (!string.IsNullOrEmpty(sqlConnectString)) { dbConnStr = sqlConnectString; } else if (!string.IsNullOrEmpty(localDbPath)) { // old installers put sql server computer name in localDbPath dbConnStr = "Server=" + localDbPath + "\\pmcsqlserver;" + "User ID=mazakpmc;Password=Fms-978"; } else { var b = new System.Data.SqlClient.SqlConnectionStringBuilder(); b.UserID = "mazakpmc"; b.Password = "******"; b.DataSource = "(local)"; dbConnStr = b.ConnectionString; } } else { dbConnStr = localDbPath; if (string.IsNullOrEmpty(dbConnStr)) { dbConnStr = "c:\\Mazak\\NFMS\\DB"; } } // log csv string logPath = cfg.GetValue <string>("Log CSV Path"); if (logPath == null || logPath == "") { logPath = "c:\\Mazak\\FMS\\Log"; } if (MazakType != MazakDbType.MazakVersionE && !System.IO.Directory.Exists(logPath)) { Log.Error("Log CSV Directory {path} does not exist. Set the directory in the config.ini file.", logPath); } else if (MazakType != MazakDbType.MazakVersionE) { Log.Information("Loading log CSV files from {logcsv}", logPath); } // general config string useStarting = cfg.GetValue <string>("Use Starting Offset For Due Date"); string useStarting2 = cfg.GetValue <string>("Use Starting Offset"); if (string.IsNullOrEmpty(useStarting)) { if (string.IsNullOrEmpty(useStarting2)) { UseStartingOffsetForDueDate = true; } else { UseStartingOffsetForDueDate = Convert.ToBoolean(useStarting2); } } else { UseStartingOffsetForDueDate = Convert.ToBoolean(useStarting); } //Perhaps this should be a new setting, but if you don't check for pallets used once //then you don't care if all faces on a pallet are full so might as well use priority //which causes pallet positions to go empty. CheckPalletsUsedOnce = !UseStartingOffsetForDueDate; ProgramDirectory = cfg.GetValue <string>("Program Directory"); if (string.IsNullOrEmpty(ProgramDirectory)) { ProgramDirectory = "C:\\NCProgs"; } // serial settings string serialPerMaterial = cfg.GetValue <string>("Assign Serial Per Material"); if (!string.IsNullOrEmpty(serialPerMaterial)) { bool result; if (bool.TryParse(serialPerMaterial, out result)) { if (!result) { st.SerialType = SerialType.AssignOneSerialPerCycle; } } } Log.Debug( "Configured UseStartingOffsetForDueDate = {useStarting}", UseStartingOffsetForDueDate); jobLog = new BlackMaple.MachineFramework.JobLogDB(st); jobLog.Open( System.IO.Path.Combine(st.DataDirectory, "log.db"), System.IO.Path.Combine(st.DataDirectory, "insp.db"), startingSerial: st.StartingSerial ); jobDB = new BlackMaple.MachineFramework.JobDB(); var jobInspName = System.IO.Path.Combine(st.DataDirectory, "jobinspection.db"); if (System.IO.File.Exists(jobInspName)) { jobDB.Open(jobInspName); } else { jobDB.Open(System.IO.Path.Combine(st.DataDirectory, "mazakjobs.db")); } _writeDB = new OpenDatabaseKitTransactionDB(dbConnStr, MazakType); if (MazakType == MazakDbType.MazakVersionE) { loadOper = new LoadOperationsFromFile(cfg, enableWatcher: true); } else if (MazakType == MazakDbType.MazakWeb) { loadOper = new LoadOperationsFromFile(cfg, enableWatcher: false); // web instead watches the log csv files } else { loadOper = null; // smooth db doesn't use the load operations file } var openReadDb = new OpenDatabaseKitReadDB(dbConnStr, MazakType, loadOper); if (MazakType == MazakDbType.MazakSmooth) { _readDB = new SmoothReadOnlyDB(dbConnStr, openReadDb); } else { _readDB = openReadDb; } queues = new MazakQueues(jobLog, jobDB, _writeDB); var sendToExternal = new SendMaterialToExternalQueue(); hold = new HoldPattern(_writeDB, _readDB, jobDB, true); var writeJobs = new WriteJobs(_writeDB, _readDB, hold, jobDB, jobLog, st, CheckPalletsUsedOnce, UseStartingOffsetForDueDate, ProgramDirectory); var decr = new DecrementPlanQty(jobDB, _writeDB, _readDB); if (MazakType == MazakDbType.MazakWeb || MazakType == MazakDbType.MazakSmooth) { logDataLoader = new LogDataWeb(logPath, jobLog, jobDB, writeJobs, sendToExternal, _readDB, queues, st); } else { #if USE_OLEDB logDataLoader = new LogDataVerE(jobLog, jobDB, sendToExternal, writeJobs, _readDB, queues, st); #else throw new Exception("Mazak Web and VerE are not supported on .NET core"); #endif } routing = new RoutingInfo(_writeDB, writeJobs, _readDB, logDataLoader, jobDB, jobLog, writeJobs, queues, decr, CheckPalletsUsedOnce, st); logDataLoader.NewEntries += OnNewLogEntries; if (loadOper != null) { loadOper.LoadActions += OnLoadActions; } }