Bozza generazione dati FL da testare...
This commit is contained in:
@@ -8,6 +8,19 @@ namespace MapoDataFiller.Filler
|
||||
{
|
||||
public class InterClays
|
||||
{
|
||||
protected int valStep = 10;
|
||||
protected int valMin = 500;
|
||||
protected int valMax = 15000;
|
||||
protected int numSec = 30;
|
||||
protected int stepMin = 50;
|
||||
protected int stepMax = 150;
|
||||
|
||||
protected int waitMin = 10;
|
||||
protected int waitMax = 240;
|
||||
|
||||
protected int numPerMax = 50;
|
||||
|
||||
protected Random rnd = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce elenco righe da caricare sul DB dato periodo indicato
|
||||
@@ -16,11 +29,80 @@ namespace MapoDataFiller.Filler
|
||||
/// <param name="fileOutReq"></param>
|
||||
/// <param name="currDay"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> GetDataRows(string fillMode, string fileOutReq, DayConf currDay)
|
||||
public SimBlock GetDataRows(string fillMode, string fileOutReq, DayConf currDay)
|
||||
{
|
||||
SimBlock answ = new SimBlock();
|
||||
List<string> flRows = new List<string>();
|
||||
List<string> evRows = new List<string>();
|
||||
int idxEv = 0;
|
||||
int idxFl = 0;
|
||||
bool doProd = false;
|
||||
int valReq = 0;
|
||||
int valAct = 0;
|
||||
// simulo periodi
|
||||
int numPer = rnd.Next(10, numPerMax);
|
||||
// calcolo durata media periodi in minuti
|
||||
double avgDurPer = (currDay.dtEnd.Subtract(currDay.dtStart).TotalMinutes) / numPer;
|
||||
double preDelay = avgDurPer / 2;
|
||||
// imposto cursore
|
||||
DateTime dtStart = currDay.dtStart.AddMinutes(preDelay);
|
||||
DateTime dtEnd = currDay.dtEnd;
|
||||
// per prima cosa aggiungo start dopo un delay di max 1/2 periodo...
|
||||
flRows.Add($"INTERCL_02;{dtStart:yyyy-MM-dd HH:mm:ss.fff};IOB-STATUS;IOB Started;{idxFl}");
|
||||
evRows.Add($"INTERCL_02;{dtStart:yyyy-MM-dd HH:mm:ss.fff};14;ND;-;1;{idxEv}");
|
||||
// calcolo durata successivi
|
||||
while (dtEnd < currDay.dtEnd)
|
||||
{
|
||||
dtStart = dtStart.AddSeconds(30);
|
||||
dtEnd = dtStart.AddMinutes(avgDurPer * rnd.Next(600, 1400) / 1000);
|
||||
// tiro a dadi x decidere SE ho pesate nel periodo... 5% dei casi
|
||||
doProd = (rnd.Next(0, 100) <= 5);
|
||||
|
||||
/*----------------------------------------
|
||||
// Gestione FluxLOG
|
||||
----------------------------------------*/
|
||||
// SE ho pesate --> genero target
|
||||
valReq = doProd ? rnd.Next(valMin / valStep, valMax / valStep) * valStep : 0;
|
||||
valAct = valReq + rnd.Next(0, valStep) * valStep;
|
||||
// genero righe x periodo e sommo
|
||||
var nextRows = IC_OX_getFlRows(dtStart, dtEnd, doProd, valReq, valAct, ref idxFl);
|
||||
// sommo righe
|
||||
answ.FlList.AddRange(nextRows);
|
||||
|
||||
/*----------------------------------------
|
||||
// Gestione EventList
|
||||
----------------------------------------*/
|
||||
}
|
||||
// ritorno
|
||||
answ.EvList = evRows;
|
||||
answ.FlList = flRows;
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected List<string> IC_OX_getFlRows(DateTime dtStart, DateTime dtEnd, bool doProd, int valReq, int valTo, ref int idxCount)
|
||||
{
|
||||
List<string> rows = new List<string>();
|
||||
|
||||
DateTime dtCurs = dtStart;
|
||||
string currRow = "";
|
||||
int valCurr = 0;
|
||||
// genera i dati secondo lo schema configurato...
|
||||
while (dtCurs < dtEnd)
|
||||
{
|
||||
currRow = $"INTERCL_02;{dtCurs:yyyy-MM-dd HH:mm:ss.fff};kgImp;{valReq};{idxCount++}";
|
||||
rows.Add(currRow);
|
||||
dtCurs = dtCurs.AddMilliseconds(rnd.Next(50, 300));
|
||||
currRow = $"INTERCL_02;{dtCurs:yyyy-MM-dd HH:mm:ss.fff};kgAct;{valReq};{idxCount++}";
|
||||
rows.Add(currRow);
|
||||
dtCurs = dtCurs.AddMilliseconds(rnd.Next(27000, 33000));
|
||||
// incremento peso... SE <= max...
|
||||
if (valCurr < valTo)
|
||||
{
|
||||
valCurr += rnd.Next(stepMin, stepMax);
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace MapoDataFiller
|
||||
{
|
||||
public class SimBlock
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public List<string> EvList { get; set; } = new List<string>();
|
||||
public List<string> FlList { get; set; } = new List<string>();
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user