public BuildCurrentStatusSpec() { var logConn = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:"); logConn.Open(); _emptyLog = new JobLogDB(new FMSSettings(), logConn); _emptyLog.CreateTables(firstSerialOnEmpty: null); var jobConn = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:"); jobConn.Open(); _jobDB = new JobDB(jobConn); _jobDB.CreateTables(); _settings = new FMSSettings(); _settings.Queues["castings"] = new QueueSize(); _settings.Queues["queueAAA"] = new QueueSize(); _settings.Queues["queueBBB"] = new QueueSize(); _settings.Queues["queueCCC"] = new QueueSize(); jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add(new BlackMaple.MachineFramework.TimespanConverter()); jsonSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); jsonSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; jsonSettings.Formatting = Formatting.Indented; jsonSettings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor; queueSyncFault = Substitute.For <IQueueSyncFault>(); queueSyncFault.CurrentQueueMismatch.Returns(false); }
public InspectionTest() { var logConn = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:"); logConn.Open(); _insp = new JobLogDB(new FMSSettings(), logConn); _insp.CreateTables(firstSerialOnEmpty: null); }
public MockServerBackend() { string path = null; // dataDir string dbFile(string f) => System.IO.Path.Combine(path, f + ".db"); if (path != null) { if (System.IO.File.Exists(dbFile("log"))) { System.IO.File.Delete(dbFile("log")); } LogDB = new JobLogDB(new FMSSettings()); LogDB.Open(dbFile("log"), dbFile("insp")); if (System.IO.File.Exists(dbFile("job"))) { System.IO.File.Delete(dbFile("job")); } JobDB = new JobDB(); JobDB.Open(dbFile("job")); } else { var conn = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:"); conn.Open(); LogDB = new JobLogDB(new FMSSettings(), conn); LogDB.CreateTables(firstSerialOnEmpty: null); conn = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:"); conn.Open(); JobDB = new JobDB(conn); JobDB.CreateTables(); } _jsonSettings = new JsonSerializerSettings(); _jsonSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); _jsonSettings.Converters.Add(new BlackMaple.MachineFramework.TimespanConverter()); _jsonSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); _jsonSettings.ConstructorHandling = Newtonsoft.Json.ConstructorHandling.AllowNonPublicDefaultConstructor; var sampleDataPath = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../sample-data/" ); // sample data starts at Jan 1, 2018. Need to offset to current month var jan1_18 = new DateTime(2018, 1, 1, 0, 0, 0, DateTimeKind.Utc); var offset = DateTime.UtcNow.AddDays(-28).Subtract(jan1_18); LoadEvents(sampleDataPath, offset); LoadJobs(sampleDataPath, offset); LoadStatus(sampleDataPath, offset); }
public WriteJobsSpec() { var logConn = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:"); logConn.Open(); _logDB = new JobLogDB(new FMSSettings(), logConn); _logDB.CreateTables(firstSerialOnEmpty: null); var jobConn = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:"); jobConn.Open(); _jobDB = new JobDB(jobConn); _jobDB.CreateTables(); _writeMock = new WriteMock(); _readMock = Substitute.For <IReadDataAccess>(); _readMock.MazakType.Returns(MazakDbType.MazakSmooth); _readMock.LoadAllData().Returns(new MazakAllData() { Schedules = new[] { // a completed schedule, should be deleted new MazakScheduleRow() { Id = 1, PartName = "part1:1:1", Comment = MazakPart.CreateComment("uniq1", new [] { 1 }, false), PlanQuantity = 15, CompleteQuantity = 15, Priority = 50, Processes = { new MazakScheduleProcessRow() { MazakScheduleRowId = 1, FixedMachineFlag = 1, ProcessNumber = 1 } } }, // a non-completed schedule, should be decremented new MazakScheduleRow() { Id = 2, PartName = "part2:1:1", Comment = MazakPart.CreateComment("uniq2", new [] { 1 }, false), PlanQuantity = 15, CompleteQuantity = 10, Priority = 50, Processes = { new MazakScheduleProcessRow() { MazakScheduleRowId = 1, FixedMachineFlag = 1, ProcessNumber = 1, ProcessMaterialQuantity = 3, ProcessExecuteQuantity = 2 } } }, }, Parts = new[] { // should be deleted, since corresponding schedule is deleted new MazakPartRow() { PartName = "part1:1:1", Comment = MazakPart.CreateComment("uniq1", new[] { 1 }, false), Processes = { new MazakPartProcessRow() { PartName = "part1:1:1", ProcessNumber = 1, FixQuantity = 5, Fixture = "fixtoremove" } } }, //should be kept, since schedule is kept new MazakPartRow() { PartName = "part2:1:1", Comment = MazakPart.CreateComment("uniq2", new[] { 1 }, false), Processes = { new MazakPartProcessRow() { PartName = "part2:1:1", ProcessNumber = 1, FixQuantity = 2, Fixture = "fixtokeep" } } }, }, Fixtures = new[] { new MazakFixtureRow() { FixtureName = "fixtoremove", Comment = "Insight" }, new MazakFixtureRow() { FixtureName = "fixtokeep", Comment = "Insight" } }, Pallets = new[] { new MazakPalletRow() { PalletNumber = 5, Fixture = "fixtoremove" }, new MazakPalletRow() { PalletNumber = 6, Fixture = "fixtokeep" } }, PalletSubStatuses = Enumerable.Empty <MazakPalletSubStatusRow>(), PalletPositions = Enumerable.Empty <MazakPalletPositionRow>(), LoadActions = Enumerable.Empty <LoadAction>(), MainPrograms = Enumerable.Concat( (new[] { "1001", "1002", "1003", "1004", "1005" }).Select(p => new MazakProgramRow() { MainProgram = p, Comment = "" }), new[] { new MazakProgramRow() { MainProgram = System.IO.Path.Combine("theprogdir", "prog-bbb-1_rev2.EIA"), Comment = "Insight:2:prog-bbb-1" }, new MazakProgramRow() { MainProgram = System.IO.Path.Combine("theprogdir", "prog-bbb-1_rev3.EIA"), Comment = "Insight:3:prog-bbb-1" } } ) }); _readMock.LoadSchedulesPartsPallets().Returns(x => new MazakSchedulesPartsPallets() { Schedules = Enumerable.Empty <MazakScheduleRow>(), Parts = _writeMock.AddParts.Parts, Pallets = _writeMock.AddParts.Pallets, PalletSubStatuses = Enumerable.Empty <MazakPalletSubStatusRow>(), PalletPositions = Enumerable.Empty <MazakPalletPositionRow>(), LoadActions = Enumerable.Empty <LoadAction>(), MainPrograms = (new[] { "1001", "1002", "1003", "1004", "1005" }).Select(p => new MazakProgramRow() { MainProgram = p, Comment = "" }), }); _settings = new FMSSettings(); _settings.Queues["castings"] = new QueueSize(); _settings.Queues["queueAAA"] = new QueueSize(); _settings.Queues["queueBBB"] = new QueueSize(); _settings.Queues["queueCCC"] = new QueueSize(); _writeJobs = new WriteJobs( _writeMock, _readMock, Substitute.For <IHoldManagement>(), _jobDB, _logDB, _settings, check: false, useStarting: true, progDir: "theprogdir"); jsonSettings = new JsonSerializerSettings(); jsonSettings.Converters.Add(new BlackMaple.MachineFramework.TimespanConverter()); jsonSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); jsonSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; jsonSettings.Formatting = Formatting.Indented; }