Added a waiting room and now the checkouts also take the number of people waiting in count for when to open

This commit is contained in:
2023-01-11 16:06:47 +01:00
parent 780f9a8c28
commit a891033a25
5 changed files with 71 additions and 62 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Caisses
}
public void Tick(GraphicalStore store)
{
if (!Open && store.AverageWaitingTime > GraphicalStore.CROSSOVER_TIME && store.GetEmptyCheckoutCount() == 0 || store.OpenCheckoutCount == 0)
if (!Open && store.AverageWaitingTime > GraphicalStore.CROSSOVER_TIME && store.GetEmptyCheckoutCount() == 0 || store.OpenCheckoutCount == 0 || store.WaitingClients.Count > MAX_CAPACITY * 2 && store.GetEmptyCheckoutCount() == 0)
{
Open = true;
}
+18 -5
View File
@@ -44,10 +44,12 @@
this.label1 = new System.Windows.Forms.Label();
this.tmrRefresh = new System.Windows.Forms.Timer(this.components);
this.tmrDraw = new System.Windows.Forms.Timer(this.components);
this.pbxWaitRoom = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pbxRayons)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbxCaisses)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxWaitRoom)).BeginInit();
this.SuspendLayout();
//
// pbxRayons
@@ -61,9 +63,9 @@
//
// pbxCaisses
//
this.pbxCaisses.Location = new System.Drawing.Point(12, 375);
this.pbxCaisses.Location = new System.Drawing.Point(12, 575);
this.pbxCaisses.Name = "pbxCaisses";
this.pbxCaisses.Size = new System.Drawing.Size(838, 246);
this.pbxCaisses.Size = new System.Drawing.Size(1044, 246);
this.pbxCaisses.TabIndex = 1;
this.pbxCaisses.TabStop = false;
//
@@ -72,7 +74,7 @@
this.groupBox1.Controls.Add(this.btnAddTime);
this.groupBox1.Controls.Add(this.btnAddClients);
this.groupBox1.Controls.Add(this.btnStartStop);
this.groupBox1.Location = new System.Drawing.Point(856, 375);
this.groupBox1.Location = new System.Drawing.Point(856, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 125);
this.groupBox1.TabIndex = 2;
@@ -115,7 +117,7 @@
this.groupBox2.Controls.Add(this.lblAvaiblePlaces);
this.groupBox2.Controls.Add(this.lblClientsWithoutCheckout);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Location = new System.Drawing.Point(856, 501);
this.groupBox2.Location = new System.Drawing.Point(856, 138);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(200, 120);
this.groupBox2.TabIndex = 6;
@@ -186,11 +188,20 @@
this.tmrDraw.Interval = 8;
this.tmrDraw.Tick += new System.EventHandler(this.tmrDraw_Tick);
//
// pbxWaitRoom
//
this.pbxWaitRoom.Location = new System.Drawing.Point(12, 375);
this.pbxWaitRoom.Name = "pbxWaitRoom";
this.pbxWaitRoom.Size = new System.Drawing.Size(1044, 194);
this.pbxWaitRoom.TabIndex = 7;
this.pbxWaitRoom.TabStop = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1062, 623);
this.ClientSize = new System.Drawing.Size(1062, 833);
this.Controls.Add(this.pbxWaitRoom);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.pbxCaisses);
@@ -202,6 +213,7 @@
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pbxWaitRoom)).EndInit();
this.ResumeLayout(false);
}
@@ -223,6 +235,7 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer tmrRefresh;
private System.Windows.Forms.Timer tmrDraw;
private System.Windows.Forms.PictureBox pbxWaitRoom;
}
}
+6 -1
View File
@@ -17,7 +17,7 @@ namespace Caisses
{
InitializeComponent();
DoubleBuffered = true;
store = new GraphicalStore(20,12,pbxRayons.Size,pbxCaisses.Size);
store = new GraphicalStore(10,12,pbxRayons.Size,pbxCaisses.Size,pbxWaitRoom.Size);
}
private void btnStartStop_Click(object sender, EventArgs e)
@@ -53,8 +53,13 @@ namespace Caisses
{
pbxCaisses.Image.Dispose();
}
if (pbxWaitRoom.Image != null)
{
pbxWaitRoom.Image.Dispose();
}
pbxRayons.Image = result[0];
pbxCaisses.Image = result[1];
pbxWaitRoom.Image = result[2];
lblClients.Text = "Clients : " + store.Clients.Count();
lblClientsWithoutCheckout.Text = "Clients without checkout : "+ store.WaitingClients.Count();
+16 -29
View File
@@ -39,16 +39,19 @@ namespace Caisses
double val = (Random.NextDouble() * (max - min) + min);
return (float)val;
}
public void Update(Size area)
public void Update(Size StoreArea, Size WaitingRoomArea)
{
//base.Tick();
Position = checkBounds(Position,area);
Position = checkBounds(Position, StoreArea, WaitingRoomArea);
Color = Color.FromArgb(ShoppingTime * 2, 0, 0);
}
public void Draw(Bitmap storeImage)
public void Draw(Bitmap storeImage, Bitmap waitingRoomImage)
{
Update(storeImage.Size);
Update(storeImage.Size, waitingRoomImage.Size);
Graphics g = Graphics.FromImage(storeImage);
if (this.State == Client.ClientState.Waiting)
g = Graphics.FromImage(waitingRoomImage);
switch (State)
{
case ClientState.Shopping:
@@ -70,32 +73,19 @@ namespace Caisses
break;
}
}
public PointF checkBounds(PointF position, Size area)
public PointF checkBounds(PointF position, Size StoreArea, Size WaitingArea)
{
PointF newPosition = new PointF(position.X, position.Y);
/*
if (position.X < 0)
Size area = StoreArea;
if (this.State == Client.ClientState.Waiting)
area = WaitingArea;
if (Position.X + Size.Width / 2 > area.Width || Position.Y + Size.Height / 2 > area.Height)
{
newPosition.X = 0;
Speed = new Point(Speed.X * -1, Speed.Y);
//Its just that sometimes when transfered from the store to the waiting room, the clients ar stuck outside the bounds
newPosition = new PointF(0,0);
}
if (position.X > area.Width)
else
{
newPosition.X = area.Width;
Speed = new Point(Speed.X * -1, Speed.Y);
}
if (position.Y < 0)
{
newPosition.Y = 0;
Speed = new Point(Speed.X, Speed.Y * -1);
}
if (position.Y > area.Height)
{
newPosition.Y = area.Height;
Speed = new Point(Speed.X, Speed.Y * -1);
}*/
if (position.X + Speed.X > 0 && position.X + Size.Width + Speed.X < area.Width)
{
newPosition.X = position.X + Speed.X;
@@ -104,9 +94,7 @@ namespace Caisses
{
float diff = Math.Abs(position.X + Speed.X);
newPosition.X = diff;
//newPosition = new Point(0, position.Y);
Speed = new PointF(Speed.X * -1, Speed.Y);
//speed.X += -1;
}
if (position.Y + Speed.Y > 0 && position.Y + Size.Height + Speed.Y < area.Height)
{
@@ -116,9 +104,8 @@ namespace Caisses
{
float diff = Math.Abs(position.Y + Speed.Y);
newPosition.Y = diff;
//newPosition = new Point(position.X, 0);
Speed = new PointF(Speed.X, Speed.Y * -1);
//speed.Y *= -1;
}
}
return newPosition;
+8 -4
View File
@@ -17,6 +17,7 @@ namespace Caisses
private int _timeOfTheDayInMinuts;
private Bitmap _shelvesCorner;
private Bitmap _checkoutCorner;
private Bitmap _waitingCorner;
private Random rnd;
/// Stats
@@ -40,19 +41,21 @@ namespace Caisses
internal List<GraphicalCheckout> Checkouts { get => _checkouts; set => _checkouts = value; }
public Bitmap ShelvesCorner { get => _shelvesCorner; set => _shelvesCorner = value; }
public Bitmap CheckoutCorner { get => _checkoutCorner; set => _checkoutCorner = value; }
public Bitmap WaitingCorner { get => _waitingCorner; set => _waitingCorner = value; }
public int TimeOfTheDayInHours
{
get { return _timeOfTheDayInMinuts / 60; }
}
public GraphicalStore(int startingHour, int checkoutNumber, Size shelvesCornerSize, Size checkoutCornerSize)
public GraphicalStore(int startingHour, int checkoutNumber, Size shelvesCornerSize, Size checkoutCornerSize, Size waitingCornerSize)
{
TimeOfTheDayInMinuts = startingHour * 60;
Clients = new List<GraphicalClient>();
Checkouts = new List<GraphicalCheckout>();
CheckoutCorner = new Bitmap(checkoutCornerSize.Width, checkoutCornerSize.Height);
ShelvesCorner = new Bitmap(shelvesCornerSize.Width, shelvesCornerSize.Height);
WaitingCorner = new Bitmap(waitingCornerSize.Width, waitingCornerSize.Height);
rnd = new Random();
FillStore(ATTENDANCE[TimeOfTheDayInHours]);
@@ -194,9 +197,10 @@ namespace Caisses
{
ShelvesCorner = new Bitmap(ShelvesCorner.Width, ShelvesCorner.Height);
CheckoutCorner = new Bitmap(CheckoutCorner.Width, CheckoutCorner.Height);
WaitingCorner = new Bitmap(WaitingCorner.Width, WaitingCorner.Height);
foreach (GraphicalClient client in Clients)
{
client.Draw(ShelvesCorner);
client.Draw(ShelvesCorner,WaitingCorner);
}
foreach (GraphicalCheckout checkout in Checkouts)
@@ -204,11 +208,11 @@ namespace Caisses
checkout.Draw(CheckoutCorner);
foreach (GraphicalClient client in checkout.Clients)
{
client.Draw(ShelvesCorner);
client.Draw(ShelvesCorner,WaitingCorner);
}
}
return new List<Bitmap> { ShelvesCorner, CheckoutCorner };
return new List<Bitmap> { ShelvesCorner, CheckoutCorner, WaitingCorner};
}
public virtual void FillStore(int amountOfNewClients)
{