92 lines
2.3 KiB
C#
92 lines
2.3 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Classe per generazione dati simulati
|
|
/// </summary>
|
|
public class SimController : IDisposable
|
|
{
|
|
|
|
#if false
|
|
protected List<Simulator>? paramList = null;
|
|
|
|
public SimController()
|
|
{
|
|
paramList = new List<Simulator>();
|
|
}
|
|
public SimController(List<Simulator> setSimParam)
|
|
{
|
|
if (setSimParam == null)
|
|
{
|
|
setSimParam = new List<Simulator>();
|
|
|
|
}
|
|
paramList = setSimParam;
|
|
}
|
|
#endif
|
|
|
|
public void Dispose()
|
|
{
|
|
// Clear database context
|
|
//Log.Info("Dispose di GWMSController");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Restituisce stato Macchina simulato come DTO
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|