using Microsoft.Extensions.Configuration; using MP.MONO.Core; using MP.MONO.Core.DTO; using NLog; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MP.MONO.Data.Controllers { /// /// Classe per generazione dati simulati /// public class SimController : IDisposable { #if false protected List? paramList = null; public SimController() { paramList = new List(); } public SimController(List setSimParam) { if (setSimParam == null) { setSimParam = new List(); } paramList = setSimParam; } #endif public void Dispose() { // Clear database context //Log.Info("Dispose di GWMSController"); } /// /// Restituisce stato Macchina simulato come DTO /// /// public MachineDTO MachineGetStatus() { Random rand = new Random(); int maxRun = 5; int maxExe = 7; MachineDTO currMachDto = new MachineDTO() { Manufacturer = "Egalware", Model = "SIM Machine", Name = "DEMO 01", SerNumber = "2022-0001", Mode = $"{(Enums.MachRunMode)rand.Next(0, maxRun)}", Status = $"{(Enums.MachExeStatus)rand.Next(0, maxExe)}" }; return currMachDto; } public ProductionDTO MachineGetProd() { // !!!FIXME TODO... è fake... Random rand = new Random(); int stdCycle = 5; ProductionDTO currMachDto = new ProductionDTO() { Order = "ODL Test", ItemCode = "ART.0000123", ProgName = "P000012", CurrQty = DateTime.Now.Minute + rand.Next(1, 40), OrderQty = 100, CycleTimeMin = rand.NextDouble() * stdCycle, Message = "...simulated data..." }; Task.Delay(400).Wait(); return currMachDto; } } }