using MP.MONO.Data.DbModels; using Microsoft.EntityFrameworkCore; using System; namespace MP.MONO.Data { public static class ModelBuilderExtensions { /// /// Estensione per seed iniziale dei dati nel DB /// /// public static void Seed(this ModelBuilder modelBuilder) { // inizializzazione dei valori di default x Machine modelBuilder.Entity().HasData( new MachineModel { MachineId = 1, Serial = "SN-0000-0000-0000", Model = "Egalware SIM", Name = "EGW-SIM-Machine", Description = "Default SIM Machine" } ); // initi valori default x eventi modelBuilder.Entity().HasData( new EventModel { CodEvent = "", Description = "NA", IsUser = false } , new EventModel { CodEvent = "Run", Description = "Running", IsUser = true } , new EventModel { CodEvent = "Setup", Description = "Machine Setup", IsUser = true } , new EventModel { CodEvent = "ProgEdit", Description = "Program Editing", IsUser = true } , new EventModel { CodEvent = "Fill", Description = "Machine Fill", IsUser = true } , new EventModel { CodEvent = "SetError", Description = "Error", IsUser = true } , new EventModel { CodEvent = "WuCd", Description = "Warm Up / CoolDown Machine", IsUser = false } , new EventModel { CodEvent = "ContrPwr", Description = "Controlled PowerOn / ShutDown", IsUser = false } , new EventModel { CodEvent = "ProgMiss", Description = "Program Missing", IsUser = true } , new EventModel { CodEvent = "HRMiss", Description = "HR Missing", IsUser = true } , new EventModel { CodEvent = "Maint", Description = "Maintenance", IsUser = true } , new EventModel { CodEvent = "Clean", Description = "Machine CleanUp", IsUser = true } , new EventModel { CodEvent = "SetPwrOff", Description = "Power OFF Declaration", IsUser = true } , new EventModel { CodEvent = "Init", Description = "Init", IsUser = false } , new EventModel { CodEvent = "PowerOff", Description = "Power OFF", IsUser = false } , new EventModel { CodEvent = "PowerOn", Description = "Power ON", IsUser = false } , new EventModel { CodEvent = "Cycle", Description = "Machining", IsUser = false } , new EventModel { CodEvent = "EndCycle", Description = "End machining", IsUser = false } , new EventModel { CodEvent = "Error", Description = "Error", IsUser = false } , new EventModel { CodEvent = "PzCount", Description = "Item Count(+1)", IsUser = false } , new EventModel { CodEvent = "StartPall", Description = "Start pallet", IsUser = false } , new EventModel { CodEvent = "EndPall", Description = "End pallet", IsUser = false } , new EventModel { CodEvent = "Manual", Description = "Manual", IsUser = false } , new EventModel { CodEvent = "LOutFull", Description = "Line Out Full", IsUser = false } , new EventModel { CodEvent = "LInEmpty", Description = "Line In Empty", IsUser = false } , new EventModel { CodEvent = "CycleTOut", Description = "Timeout Std CycleTime", IsUser = false } , new EventModel { CodEvent = "RMatMiss", Description = "Raw Material Missing", IsUser = true } , new EventModel { CodEvent = "Emergency", Description = "Emergency", IsUser = false } , new EventModel { CodEvent = "ToolRepl", Description = "Tool Replacement", IsUser = true } , new EventModel { CodEvent = "CncAlam", Description = "CNC Alarm", IsUser = false } , new EventModel { CodEvent = "PlcAlam", Description = "PLC Alarm", IsUser = false } , new EventModel { CodEvent = "Warning", Description = "Warning State", IsUser = false } , new EventModel { CodEvent = "Message", Description = "Machine Message", IsUser = false } , new EventModel { CodEvent = "PzIncr", Description = "Item Count Increment", IsUser = false } , new EventModel { CodEvent = "PzSet", Description = "Item Count Set", IsUser = false } , new EventModel { CodEvent = "UserComm", Description = "User Comment", IsUser = true } ); // initi valori default x stati modelBuilder.Entity().HasData( new StatusModel { Prior = 0, CodStatus = "", Description = "NA", CssClass = "dark", Group = "NA" } // alta priorità , new StatusModel { Prior = 5, CodStatus = "Error", Description = "Error", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 5, CodStatus = "Emergency", Description = "Emergency", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 4, CodStatus = "Manual", Description = "Manual", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 4, CodStatus = "PzProd", Description = "Item Produced", CssClass = "warning", Group = "MicroYellow" } , new StatusModel { Prior = 4, CodStatus = "Unkn", Description = "Unknown Stop", CssClass = "warning", Group = "MicroYellow" } // fermi rossi , new StatusModel { Prior = 1, CodStatus = "ProgMissing", Description = "Program Missing", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "HRMissing", Description = "HR Missing", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "Maint", Description = "Maintenance", CssClass = "warning", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "LineOutFull", Description = "Line Out Full", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "LineInEmpty", Description = "Line In Empty", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "RawMatMiss", Description = "Raw Material Missing", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "CncAlam", Description = "CNC Alarm", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "PlcAlam", Description = "PLC Alarm", CssClass = "danger", Group = "StopRed" } // fermo blu non gestito/qualificato , new StatusModel { Prior = 1, CodStatus = "WUpCDown", Description = "Warm Up / CoolDown Machine", CssClass = "primary", Group = "WaitBlue" } , new StatusModel { Prior = 1, CodStatus = "ContrPOnSDown", Description = "Controller PowerOn / ShutDown", CssClass = "primary", Group = "WaitBlue" } , new StatusModel { Prior = 1, CodStatus = "Init", Description = "Init", CssClass = "primary", Group = "WaitBlue" } , new StatusModel { Prior = 1, CodStatus = "PowerOn", Description = "Power ON", CssClass = "primary", Group = "WaitBlue" } , new StatusModel { Prior = 1, CodStatus = "TimeoutCycle", Description = "Timeout Std CycleTime", CssClass = "primary", Group = "WaitBlue" } , new StatusModel { Prior = 1, CodStatus = "Waiting", Description = "Waiting State", CssClass = "primary", Group = "WaitBlue" } // fermo giallo manuale , new StatusModel { Prior = 1, CodStatus = "ProgEdit", Description = "Program Editing", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "Setup", Description = "Machine Setup", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "Clean", Description = "Machine CleanUp", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "Fill", Description = "Machine Fill", CssClass = "warning", Group = "MicroYellow" } , new StatusModel { Prior = 1, CodStatus = "ToolReplace", Description = "Tool Replacement", CssClass = "warning", Group = "MicroYellow" } , new StatusModel { Prior = 1, CodStatus = "Warning", Description = "Warning State", CssClass = "warning", Group = "MicroYellow" } // macchina spenta , new StatusModel { Prior = 1, CodStatus = "PowerOff", Description = "Power OFF", CssClass = "secondary", Group = "Gray" } // produzione , new StatusModel { Prior = 1, CodStatus = "Run", Description = "Running", CssClass = "success", Group = "Green" } , new StatusModel { Prior = 1, CodStatus = "Cycle", Description = "Machining", CssClass = "success", Group = "Green" } // eventi cablati da status macchina... , new StatusModel { Prior = 1, CodStatus = "MS_000", Description = "UNDEFINED", CssClass = "secondary", Group = "Gray" } , new StatusModel { Prior = 1, CodStatus = "MS_001", Description = "POWEROFF", CssClass = "secondary", Group = "Gray" } , new StatusModel { Prior = 1, CodStatus = "MS_002", Description = "AUTOMATIC", CssClass = "success", Group = "Green" } , new StatusModel { Prior = 1, CodStatus = "MS_003", Description = "EDIT", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "MS_004", Description = "SEMIAUTOMATIC", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "MS_005", Description = "MANUAL_JOG", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "MS_006", Description = "ALARM", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "MS_007", Description = "ESTOP", CssClass = "danger", Group = "StopRed" } , new StatusModel { Prior = 1, CodStatus = "MS_008", Description = "MDI", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "MS_009", Description = "STEP", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "MS_010", Description = "INC_JOG", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "MS_011", Description = "PROFILE", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "MS_012", Description = "HOME", CssClass = "warning", Group = "ManYellow" } , new StatusModel { Prior = 1, CodStatus = "MS_013", Description = "HANDWHEEL", CssClass = "warning", Group = "ManYellow" } ); // inizializzazione dei valori di default x Tipologia counters modelBuilder.Entity().HasData( new CounterModel { CCode = "MacPowerOn", Description = "Machine Power On", CodAlias = "MACHINE STATUS" }, new CounterModel { CCode = "CycleProc01", Description = "Process 1 on Cycle state", CodAlias = "PROCESS STATUS" }, new CounterModel { CCode = "SpindleTorque01", Description = "Spindle 01 Torque % > 0", CodAlias = "SPINDLE 1 LOAD" }, new CounterModel { CCode = "SpindleTorque02", Description = "Spindle 02 Torque % > 0", CodAlias = "SPINDLE 2 LOAD" }, new CounterModel { CCode = "SpindleTorque03", Description = "Spindle 03 Torque % > 0", CodAlias = "SPINDLE 3 LOAD" }, new CounterModel { CCode = "SpindleTorque04", Description = "Spindle 04 Torque % > 0", CodAlias = "SPINDLE 4 LOAD" }, new CounterModel { CCode = "LMCheckElapsed", Description = "Time Elapsed from last full Manufacturer Check", CodAlias = "Manual Fix" } ); // inizializzazione dei valori di default x Tipologia UserTeam modelBuilder.Entity().HasData( new PMUTModel { PMUTCode = "TrainOp", Description = "Trained Operator" }, new PMUTModel { PMUTCode = "MaintServ", Description = "Maintenance Service" }, new PMUTModel { PMUTCode = "DevSupp", Description = "Device Supplier" }, new PMUTModel { PMUTCode = "MultiaxServ", Description = "Multiax Service" } ); // inizializzazione dei valori di default x Topic di Prev Maint modelBuilder.Entity().HasData( new PMTaskTopicModel { PMTCode = "Mechanical", Description = "Mechanical system" }, new PMTaskTopicModel { PMTCode = "Electro", Description = "Electrical system" }, new PMTaskTopicModel { PMTCode = "Lubro", Description = "Lubrication system" }, new PMTaskTopicModel { PMTCode = "Coolant", Description = "Coolant system" }, new PMTaskTopicModel { PMTCode = "Preumo", Description = "Pneumatic system" }, new PMTaskTopicModel { PMTCode = "Hydro", Description = "Hydraulic system" }, new PMTaskTopicModel { PMTCode = "Safety", Description = "Enclosure/Safety system" }, new PMTaskTopicModel { PMTCode = "Suction", Description = "Suction system" }, new PMTaskTopicModel { PMTCode = "GeoAdj", Description = "Geometrical system" } ); // inizializzazione dei valori di default x Machine Group modelBuilder.Entity().HasData( new PMMGroupModel { PMMGCode = "Whole", Description = "Whole Machine" }, new PMMGroupModel { PMMGCode = "Load", Description = "Part loader/unloader" }, new PMMGroupModel { PMMGCode = "MovBelts", Description = "Part moving belts" }, new PMMGroupModel { PMMGCode = "MovRoll", Description = "Part moving rollers" }, new PMMGroupModel { PMMGCode = "Axis", Description = "Machining axis" }, new PMMGroupModel { PMMGCode = "Spindles", Description = "Tool spindles" }, new PMMGroupModel { PMMGCode = "ToolChange", Description = "Automatic tool changer" }, new PMMGroupModel { PMMGCode = "Cabinet", Description = "Electrical cabinet" }, new PMMGroupModel { PMMGCode = "ChipConv", Description = "Chips conveyor" }, new PMMGroupModel { PMMGCode = "DustSuct", Description = "Dust suction" }, new PMMGroupModel { PMMGCode = "OpPanel", Description = "Operator pannel" }, new PMMGroupModel { PMMGCode = "Access", Description = "Accessories" } ); } } }