1
This commit is contained in:
29
Assets/AGVNeedsScanner.cs
Normal file
29
Assets/AGVNeedsScanner.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using NUnit.Framework;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace XED.VirtualFactory
|
||||||
|
{
|
||||||
|
public class AGVNeedsScanner : NeedsScanner
|
||||||
|
{
|
||||||
|
private readonly VirtualFactoryManager vfManager;
|
||||||
|
AGVManager manager;
|
||||||
|
public AGVNeedsScanner(VirtualFactoryManager vfManager, AGVManager agvManager)
|
||||||
|
{
|
||||||
|
this.vfManager = vfManager;
|
||||||
|
manager = agvManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Scanning()
|
||||||
|
{
|
||||||
|
CheckAGVCount();
|
||||||
|
ScanningComplete();
|
||||||
|
}
|
||||||
|
void CheckAGVCount()
|
||||||
|
{
|
||||||
|
if (manager.agvs.Count < vfManager.maxAGVCount)
|
||||||
|
{
|
||||||
|
needs.Add(FactoryNeeds.GenerateAGV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/AGVNeedsScanner.cs.meta
Normal file
2
Assets/AGVNeedsScanner.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 467b71fac96c5774c8c7f08ac58f9496
|
||||||
19
Assets/NeedsScanner.cs
Normal file
19
Assets/NeedsScanner.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace XED.VirtualFactory
|
||||||
|
{
|
||||||
|
public abstract class NeedsScanner
|
||||||
|
{
|
||||||
|
protected List<FactoryNeeds> needs = new();
|
||||||
|
public event Action<NeedsScanner, List<FactoryNeeds>> onScanningComplete;
|
||||||
|
|
||||||
|
public abstract void Scanning();
|
||||||
|
|
||||||
|
protected void ScanningComplete()
|
||||||
|
{
|
||||||
|
onScanningComplete.Invoke(this, needs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/NeedsScanner.cs.meta
Normal file
2
Assets/NeedsScanner.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9161584bea128bd4682c86acad11beca
|
||||||
31
Assets/ResourceNeedsScanner.cs
Normal file
31
Assets/ResourceNeedsScanner.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace XED.VirtualFactory
|
||||||
|
{
|
||||||
|
public class ResourceNeedsScanner : NeedsScanner
|
||||||
|
{
|
||||||
|
private readonly PortMap portMap;
|
||||||
|
|
||||||
|
public ResourceNeedsScanner(PortMap portMap)
|
||||||
|
{
|
||||||
|
this.portMap = portMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Scanning()
|
||||||
|
{
|
||||||
|
GeneratePortCheck();
|
||||||
|
ScanningComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GeneratePortCheck()
|
||||||
|
{
|
||||||
|
if(portMap.TryGetEmptyGeneratePorts(out var ports))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ports.Count; i++)
|
||||||
|
{
|
||||||
|
needs.Add(FactoryNeeds.GenerateLoad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/ResourceNeedsScanner.cs.meta
Normal file
2
Assets/ResourceNeedsScanner.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5dd1a0ad71ecdc645894bbfbdf539446
|
||||||
@@ -253,12 +253,12 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 116334308}
|
m_GameObject: {fileID: 116334308}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 850406314}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &116334310
|
--- !u!114 &116334310
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
@@ -281,8 +281,6 @@ MonoBehaviour:
|
|||||||
startNode: {fileID: 1172928290}
|
startNode: {fileID: 1172928290}
|
||||||
stackerHasEmptyCell: 0
|
stackerHasEmptyCell: 0
|
||||||
maxAGVCount: 1
|
maxAGVCount: 1
|
||||||
agvIsLack: 0
|
|
||||||
loadIsLack: 0
|
|
||||||
needs:
|
needs:
|
||||||
--- !u!1001 &125296021
|
--- !u!1001 &125296021
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
@@ -1221,6 +1219,50 @@ MonoBehaviour:
|
|||||||
unLoadSocket: {fileID: 0}
|
unLoadSocket: {fileID: 0}
|
||||||
portType: 0
|
portType: 0
|
||||||
loader: {fileID: 1832015431}
|
loader: {fileID: 1832015431}
|
||||||
|
--- !u!1 &696006662
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 696006663}
|
||||||
|
- component: {fileID: 696006664}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: StackerCraneManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &696006663
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 696006662}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 850406314}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &696006664
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 696006662}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ed97dbd476f7a154c86010b3f67bc371, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &736132299
|
--- !u!1 &736132299
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1252,6 +1294,40 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1554807645}
|
m_Father: {fileID: 1554807645}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &850406313
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 850406314}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Managers
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &850406314
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 850406313}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 116334309}
|
||||||
|
- {fileID: 1133980572}
|
||||||
|
- {fileID: 696006663}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &878306402
|
--- !u!1 &878306402
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1714,12 +1790,12 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1133980571}
|
m_GameObject: {fileID: 1133980571}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 850406314}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &1133980573
|
--- !u!114 &1133980573
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
@@ -2943,7 +3019,6 @@ SceneRoots:
|
|||||||
- {fileID: 544137894}
|
- {fileID: 544137894}
|
||||||
- {fileID: 1858000805}
|
- {fileID: 1858000805}
|
||||||
- {fileID: 1193906775}
|
- {fileID: 1193906775}
|
||||||
- {fileID: 1133980572}
|
- {fileID: 850406314}
|
||||||
- {fileID: 125296021}
|
- {fileID: 125296021}
|
||||||
- {fileID: 109703751}
|
- {fileID: 109703751}
|
||||||
- {fileID: 116334309}
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace XED.VirtualFactory
|
|||||||
{
|
{
|
||||||
public enum AGVState
|
public enum AGVState
|
||||||
{
|
{
|
||||||
Idle,
|
IdleReady,
|
||||||
Moving,
|
Moving,
|
||||||
Charging,
|
Charging,
|
||||||
Loading,
|
Loading,
|
||||||
@@ -26,7 +26,8 @@ namespace XED.VirtualFactory
|
|||||||
MoveEnd,
|
MoveEnd,
|
||||||
LoadEnd,
|
LoadEnd,
|
||||||
UnloadReady,
|
UnloadReady,
|
||||||
UnloadEnd
|
UnloadEnd,
|
||||||
|
Idle
|
||||||
}
|
}
|
||||||
|
|
||||||
public AGVState state;
|
public AGVState state;
|
||||||
@@ -51,11 +52,13 @@ namespace XED.VirtualFactory
|
|||||||
Vector3 moveStartPos;
|
Vector3 moveStartPos;
|
||||||
Vector3 nextTargetPos;
|
Vector3 nextTargetPos;
|
||||||
public AGVNode nextNode;
|
public AGVNode nextNode;
|
||||||
|
internal Action<AGV> onCompleteTask;
|
||||||
|
|
||||||
internal bool isBusy => actionQueue.Count > 0;
|
internal bool isBusy => actionQueue.Count > 0;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
updateAction = Idleing;
|
updateAction = IdleReady;
|
||||||
lift = GetComponentInChildren<AGVLift>();
|
lift = GetComponentInChildren<AGVLift>();
|
||||||
liftUpPosition = lift.transform.localPosition;
|
liftUpPosition = lift.transform.localPosition;
|
||||||
liftDownPosition = lift.transform.localPosition;
|
liftDownPosition = lift.transform.localPosition;
|
||||||
@@ -67,8 +70,11 @@ namespace XED.VirtualFactory
|
|||||||
Debug.Log($"{name} is State Changed: {state} -> {newState}");
|
Debug.Log($"{name} is State Changed: {state} -> {newState}");
|
||||||
switch (newState)
|
switch (newState)
|
||||||
{
|
{
|
||||||
|
case AGVState.IdleReady:
|
||||||
|
updateAction = IdleReady;
|
||||||
|
break;
|
||||||
case AGVState.Idle:
|
case AGVState.Idle:
|
||||||
updateAction = Idleing;
|
updateAction = Idle;
|
||||||
break;
|
break;
|
||||||
case AGVState.MoveReady:
|
case AGVState.MoveReady:
|
||||||
updateAction = MoveReady;
|
updateAction = MoveReady;
|
||||||
@@ -125,6 +131,14 @@ namespace XED.VirtualFactory
|
|||||||
state = newState;
|
state = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Idle()
|
||||||
|
{
|
||||||
|
if(actionQueue.Count > 0)
|
||||||
|
{
|
||||||
|
ExecuteNextAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LiftDownEnd()
|
private void LiftDownEnd()
|
||||||
{
|
{
|
||||||
ChangeState(AGVState.Unloading);
|
ChangeState(AGVState.Unloading);
|
||||||
@@ -132,7 +146,7 @@ namespace XED.VirtualFactory
|
|||||||
|
|
||||||
private void UnloadEnd()
|
private void UnloadEnd()
|
||||||
{
|
{
|
||||||
ChangeState(AGVState.Idle);
|
ChangeState(AGVState.IdleReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Unloading()
|
private void Unloading()
|
||||||
@@ -159,7 +173,7 @@ namespace XED.VirtualFactory
|
|||||||
}
|
}
|
||||||
private void LoadEnd()
|
private void LoadEnd()
|
||||||
{
|
{
|
||||||
ChangeState(AGVState.Idle);
|
ChangeState(AGVState.IdleReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LiftUpEnd()
|
private void LiftUpEnd()
|
||||||
@@ -174,7 +188,7 @@ namespace XED.VirtualFactory
|
|||||||
if (target.isEmpty)
|
if (target.isEmpty)
|
||||||
{
|
{
|
||||||
Debug.Log($"{target} is Empty Load!");
|
Debug.Log($"{target} is Empty Load!");
|
||||||
ChangeState(AGVState.Idle);
|
ChangeState(AGVState.IdleReady);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +245,7 @@ namespace XED.VirtualFactory
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float moveDistance;
|
||||||
private void MoveReady()
|
private void MoveReady()
|
||||||
{
|
{
|
||||||
currentMovePath = (currentAction as AGVMoveAction).path;
|
currentMovePath = (currentAction as AGVMoveAction).path;
|
||||||
@@ -241,6 +255,7 @@ namespace XED.VirtualFactory
|
|||||||
Quaternion targetRotation = Quaternion.LookRotation(direction);
|
Quaternion targetRotation = Quaternion.LookRotation(direction);
|
||||||
moveStartPos = transform.position;
|
moveStartPos = transform.position;
|
||||||
|
|
||||||
|
moveDistance = Vector3.Distance(moveStartPos, nextTargetPos);
|
||||||
if (Quaternion.Angle(transform.rotation, targetRotation) > 1f)
|
if (Quaternion.Angle(transform.rotation, targetRotation) > 1f)
|
||||||
{
|
{
|
||||||
ChangeState(AGVState.RotateReady);
|
ChangeState(AGVState.RotateReady);
|
||||||
@@ -250,7 +265,7 @@ namespace XED.VirtualFactory
|
|||||||
}
|
}
|
||||||
private void Moving()
|
private void Moving()
|
||||||
{
|
{
|
||||||
moveProgress += (spec.maxSpeed * Time.deltaTime);
|
moveProgress += (spec.maxSpeed * Time.deltaTime)/moveDistance;
|
||||||
transform.position = Vector3.Lerp(moveStartPos, nextTargetPos, moveProgress);
|
transform.position = Vector3.Lerp(moveStartPos, nextTargetPos, moveProgress);
|
||||||
|
|
||||||
if (moveProgress>=1f)
|
if (moveProgress>=1f)
|
||||||
@@ -272,15 +287,20 @@ namespace XED.VirtualFactory
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChangeState(AGVState.Idle);
|
ChangeState(AGVState.IdleReady);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Idleing()
|
void IdleReady()
|
||||||
{
|
{
|
||||||
if(actionQueue.Count > 0)
|
if(actionQueue.Count > 0)
|
||||||
{
|
{
|
||||||
ExecuteNextAction();
|
ExecuteNextAction();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
onCompleteTask?.Invoke(this);
|
||||||
|
ChangeState(AGVState.Idle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForceSet(AGVNode node)
|
public void ForceSet(AGVNode node)
|
||||||
|
|||||||
@@ -5,11 +5,5 @@ namespace XED.VirtualFactory
|
|||||||
{
|
{
|
||||||
public class GeneratePort : OutputPort
|
public class GeneratePort : OutputPort
|
||||||
{
|
{
|
||||||
|
|
||||||
public override void AfterAwake()
|
|
||||||
{
|
|
||||||
base.AfterAwake();
|
|
||||||
Debug.Log("GeneratePort AfterAwake");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,10 +14,12 @@ namespace XED.VirtualFactory
|
|||||||
public virtual void Load(Product load)
|
public virtual void Load(Product load)
|
||||||
{
|
{
|
||||||
Debug.Log($"{name} is load");
|
Debug.Log($"{name} is load");
|
||||||
|
|
||||||
load.transform.SetParent(loadPivot);
|
load.transform.SetParent(loadPivot);
|
||||||
load.transform.localPosition = Vector3.zero;
|
load.transform.localPosition = Vector3.zero;
|
||||||
currentLoad = load;
|
|
||||||
load.LocationUpdate(this);
|
load.LocationUpdate(this);
|
||||||
|
|
||||||
|
currentLoad = load;
|
||||||
onLoadEvent?.Invoke();
|
onLoadEvent?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,5 +62,18 @@ namespace XED.VirtualFactory
|
|||||||
inputPort = null;
|
inputPort = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal bool TryGetEmptyGeneratePorts(out List<GeneratePort> ports)
|
||||||
|
{
|
||||||
|
ports = new List<GeneratePort>();
|
||||||
|
foreach (var p in this.ports)
|
||||||
|
{
|
||||||
|
if (p is GeneratePort pt && pt.isEmpty)
|
||||||
|
{
|
||||||
|
ports.Add(pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ports.Count > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 24cfa40753282b845b69548571a1a451, type: 3}
|
m_Script: {fileID: 11500000, guid: 24cfa40753282b845b69548571a1a451, type: 3}
|
||||||
m_Name: AGVSpecData
|
m_Name: AGVSpecData
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
maxSpeed: 2
|
maxSpeed: 10
|
||||||
maxCurveSpeed: 2
|
maxCurveSpeed: 2
|
||||||
slowSpeed: 5
|
slowSpeed: 5
|
||||||
slowCurveSpeed: 3
|
slowCurveSpeed: 3
|
||||||
|
|||||||
@@ -40,11 +40,12 @@ namespace XED.VirtualFactory
|
|||||||
float bucketEnd;
|
float bucketEnd;
|
||||||
float pillarMoveProgress;
|
float pillarMoveProgress;
|
||||||
float bucketMoveProgress;
|
float bucketMoveProgress;
|
||||||
|
public Action<StackerCrane> onCompleteTask;
|
||||||
internal bool hasEmptyCell => cells.Any(cell => cell.isEmpty);
|
internal bool hasEmptyCell => cells.Any(cell => cell.isEmpty);
|
||||||
|
|
||||||
public enum StackerCraneState
|
public enum StackerCraneState
|
||||||
{
|
{
|
||||||
Idle,
|
IdleReady,
|
||||||
TaskReady,
|
TaskReady,
|
||||||
MoveReady,
|
MoveReady,
|
||||||
Move,
|
Move,
|
||||||
@@ -60,6 +61,7 @@ namespace XED.VirtualFactory
|
|||||||
LoadEnd,
|
LoadEnd,
|
||||||
Unload,
|
Unload,
|
||||||
UnloadEnd,
|
UnloadEnd,
|
||||||
|
Idle,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@@ -67,24 +69,18 @@ namespace XED.VirtualFactory
|
|||||||
updateAction.Invoke();
|
updateAction.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action<StackerCrane> onInputLoadEvent;
|
||||||
|
internal Action<StackerCrane> onLoadForkEvent;
|
||||||
|
|
||||||
public override void AfterAwake()
|
public override void AfterAwake()
|
||||||
{
|
{
|
||||||
ChangeState(StackerCraneState.Idle);
|
ChangeState(StackerCraneState.IdleReady);
|
||||||
cells = Storage.GetComponentsInChildren<Loader>().ToList();
|
cells = Storage.GetComponentsInChildren<Loader>().ToList();
|
||||||
inputPort.onLoadEvent += OnLoadInputPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnLoadInputPort()
|
|
||||||
{
|
|
||||||
Debug.Log($"On Load Stacker InputPort");
|
|
||||||
if (autoInput)
|
|
||||||
{
|
|
||||||
AddTask(new InputTask());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTask(StackerCraneTask task)
|
public void AddTask(StackerCraneTask task)
|
||||||
{
|
{
|
||||||
|
Debug.Log($"{name} on Add Task");
|
||||||
taskQueue.Enqueue(task);
|
taskQueue.Enqueue(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +88,9 @@ namespace XED.VirtualFactory
|
|||||||
{
|
{
|
||||||
switch (newState)
|
switch (newState)
|
||||||
{
|
{
|
||||||
|
case StackerCraneState.IdleReady:
|
||||||
|
updateAction = IdleReady;
|
||||||
|
break;
|
||||||
case StackerCraneState.Idle:
|
case StackerCraneState.Idle:
|
||||||
updateAction = Idle;
|
updateAction = Idle;
|
||||||
break;
|
break;
|
||||||
@@ -143,6 +142,14 @@ namespace XED.VirtualFactory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Idle()
|
||||||
|
{
|
||||||
|
if (taskQueue.Count > 0)
|
||||||
|
{
|
||||||
|
ChangeState(StackerCraneState.TaskReady);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UnloadEnd()
|
private void UnloadEnd()
|
||||||
{
|
{
|
||||||
ChangeState(StackerCraneState.ForkOut);
|
ChangeState(StackerCraneState.ForkOut);
|
||||||
@@ -157,6 +164,7 @@ namespace XED.VirtualFactory
|
|||||||
private void LoadEnd()
|
private void LoadEnd()
|
||||||
{
|
{
|
||||||
forkProgress = 0f;
|
forkProgress = 0f;
|
||||||
|
onLoadForkEvent?.Invoke(this);
|
||||||
ChangeState(StackerCraneState.ForkOut);
|
ChangeState(StackerCraneState.ForkOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +227,7 @@ namespace XED.VirtualFactory
|
|||||||
{
|
{
|
||||||
if (actionQueue.Count == 0)
|
if (actionQueue.Count == 0)
|
||||||
{
|
{
|
||||||
ChangeState(StackerCraneState.Idle);
|
ChangeState(StackerCraneState.IdleReady);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentAction = actionQueue.Dequeue();
|
currentAction = actionQueue.Dequeue();
|
||||||
@@ -234,11 +242,11 @@ namespace XED.VirtualFactory
|
|||||||
ChangeState(StackerCraneState.MoveReady);
|
ChangeState(StackerCraneState.MoveReady);
|
||||||
break;
|
break;
|
||||||
case StackerCraneMoveToEmptyCellAction moveToEmptyCellAction:
|
case StackerCraneMoveToEmptyCellAction moveToEmptyCellAction:
|
||||||
moveTarget = cells.FirstOrDefault(cell => cell.isEmpty);
|
moveTarget = cells.First(cell => cell.isEmpty);
|
||||||
ChangeState(StackerCraneState.MoveReady);
|
ChangeState(StackerCraneState.MoveReady);
|
||||||
break;
|
break;
|
||||||
case StackerCraneMoveToFullCellAction moveToFullCellAction:
|
case StackerCraneMoveToFullCellAction moveToFullCellAction:
|
||||||
moveTarget = cells.FirstOrDefault(cell => !cell.isEmpty);
|
moveTarget = cells.Last(cell => !cell.isEmpty);
|
||||||
ChangeState(StackerCraneState.MoveReady);
|
ChangeState(StackerCraneState.MoveReady);
|
||||||
break;
|
break;
|
||||||
case StackerCraneLoadAction loadAction:
|
case StackerCraneLoadAction loadAction:
|
||||||
@@ -294,12 +302,17 @@ namespace XED.VirtualFactory
|
|||||||
ChangeState(StackerCraneState.ActionReady);
|
ChangeState(StackerCraneState.ActionReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Idle()
|
private void IdleReady()
|
||||||
{
|
{
|
||||||
if(taskQueue.Count > 0)
|
if(taskQueue.Count > 0)
|
||||||
{
|
{
|
||||||
ChangeState(StackerCraneState.TaskReady);
|
ChangeState(StackerCraneState.TaskReady);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
onCompleteTask?.Invoke(this);
|
||||||
|
ChangeState(StackerCraneState.Idle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -7,26 +8,51 @@ namespace XED.VirtualFactory
|
|||||||
{
|
{
|
||||||
public class StackerCraneManager : MonoBehaviour, ISingle
|
public class StackerCraneManager : MonoBehaviour, ISingle
|
||||||
{
|
{
|
||||||
private HashSet<StackerCrane> stackerCranes = new HashSet<StackerCrane>();
|
public StackerCrane[] stackerCranes;
|
||||||
private StackerCraneLog stackerCraneLog;
|
void Awake()
|
||||||
|
|
||||||
public override void AfterAwake()
|
|
||||||
{
|
{
|
||||||
stackerCraneLog = FindSingle<StackerCraneLog>();
|
stackerCranes = FindObjectsByType<StackerCrane>(FindObjectsSortMode.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitStackerCrane(StackerCrane stackerCrane)
|
public bool TryGetEmptyInputStackerCranes(out List<StackerCrane> cranes)
|
||||||
{
|
{
|
||||||
bool added = stackerCranes.Add(stackerCrane);
|
cranes = new();
|
||||||
|
|
||||||
//if (added)
|
foreach (var crane in stackerCranes)
|
||||||
//{
|
{
|
||||||
// stackerCrane.onTaskReadyCompletedEvent += stackerCraneLog.TaskReadyLog;
|
if (crane.inputPort.isEmpty)
|
||||||
// stackerCrane.onTaskEndCompletedEvent += stackerCraneLog.TaskEndLogLog;
|
{
|
||||||
// stackerCrane.onStateChangeEvent += stackerCraneLog.StateChangeLog;
|
cranes.Add(crane);
|
||||||
// stackerCrane.onAddTaskCompletedEvent += stackerCraneLog.TaskAddLog;
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return cranes.Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool TryGetStackerbleStackerCranes(out List<StackerCrane> cranes)
|
||||||
|
{
|
||||||
|
cranes = new List<StackerCrane>();
|
||||||
|
foreach(var crane in stackerCranes)
|
||||||
|
{
|
||||||
|
if(!crane.inputPort.isEmpty && crane.hasEmptyCell)
|
||||||
|
{
|
||||||
|
cranes.Add(crane);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cranes.Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool TryGetUnloaderbleStacker(out List<StackerCrane> cranes)
|
||||||
|
{
|
||||||
|
cranes = new();
|
||||||
|
foreach (var crane in stackerCranes)
|
||||||
|
{
|
||||||
|
if (crane.outputPort.isEmpty && !crane.hasEmptyCell)
|
||||||
|
{
|
||||||
|
cranes.Add(crane);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cranes.Count > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
56
Assets/StackerCraneNeedsScanner.cs
Normal file
56
Assets/StackerCraneNeedsScanner.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace XED.VirtualFactory
|
||||||
|
{
|
||||||
|
public class StackerCraneNeedsScanner : NeedsScanner
|
||||||
|
{
|
||||||
|
private readonly VirtualFactoryManager vfManager;
|
||||||
|
private readonly StackerCraneManager stackerCraneManager;
|
||||||
|
|
||||||
|
public StackerCraneNeedsScanner(VirtualFactoryManager vfManager, StackerCraneManager stackerCraneManager)
|
||||||
|
{
|
||||||
|
this.vfManager = vfManager;
|
||||||
|
this.stackerCraneManager = stackerCraneManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Scanning()
|
||||||
|
{
|
||||||
|
CheckInputLoadNeeds();
|
||||||
|
CheckStackingTaskNeeds();
|
||||||
|
CheckLoadOutTaskNeeds();
|
||||||
|
ScanningComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckLoadOutTaskNeeds()
|
||||||
|
{
|
||||||
|
if(stackerCraneManager.TryGetUnloaderbleStacker(out List<StackerCrane> cranes))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < cranes.Count; ++i)
|
||||||
|
{
|
||||||
|
needs.Add(FactoryNeeds.StackerLoadOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckStackingTaskNeeds()
|
||||||
|
{
|
||||||
|
if(stackerCraneManager.TryGetStackerbleStackerCranes(out var cranes))
|
||||||
|
{
|
||||||
|
for(int i =0;i<cranes.Count; ++i)
|
||||||
|
{
|
||||||
|
needs.Add(FactoryNeeds.Stacking);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckInputLoadNeeds()
|
||||||
|
{
|
||||||
|
if(stackerCraneManager.TryGetEmptyInputStackerCranes(out var cranes))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < cranes.Count; ++i)
|
||||||
|
needs.Add(FactoryNeeds.StackerInputLoad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/StackerCraneNeedsScanner.cs.meta
Normal file
2
Assets/StackerCraneNeedsScanner.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1d7a9b8fa70a9fc4bbbf4e4da4c7af2e
|
||||||
@@ -1,11 +1,21 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XED.VirtualFactory;
|
using XED.VirtualFactory;
|
||||||
|
|
||||||
namespace XED
|
namespace XED
|
||||||
{
|
{
|
||||||
|
public enum FactoryNeeds
|
||||||
|
{
|
||||||
|
GenerateAGV,
|
||||||
|
StackerInputLoad,
|
||||||
|
Stacking,
|
||||||
|
GenerateLoad,
|
||||||
|
StackerLoadOut,
|
||||||
|
}
|
||||||
|
|
||||||
public class VirtualFactoryManager : MonoBehaviour
|
public class VirtualFactoryManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public List<StackerCrane> stackerCranes = new();
|
public List<StackerCrane> stackerCranes = new();
|
||||||
@@ -18,19 +28,17 @@ namespace XED
|
|||||||
|
|
||||||
public bool stackerHasEmptyCell;
|
public bool stackerHasEmptyCell;
|
||||||
public int maxAGVCount = 4;
|
public int maxAGVCount = 4;
|
||||||
public enum FactoryNeeds
|
|
||||||
{
|
|
||||||
NeedAGV,
|
|
||||||
NeedLoad,
|
|
||||||
NeedStackerInputLoad,
|
|
||||||
NeedStackerInput,
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool agvIsLack;
|
|
||||||
public bool loadIsLack;
|
|
||||||
public List<FactoryNeeds> needs = new();
|
public List<FactoryNeeds> needs = new();
|
||||||
public event Action scanningAction;
|
|
||||||
public event Action solutionAction;
|
public AGVNeedsScanner agvNeedScanner;
|
||||||
|
public ResourceNeedsScanner resourceNeedsChecker;
|
||||||
|
public StackerCraneNeedsScanner stackerNeedsChecker;
|
||||||
|
public List<NeedsScanner> scanners = new();
|
||||||
|
|
||||||
|
HashSet<StackerCrane> stackingReadys = new();
|
||||||
|
private StackerCraneManager stackerCraneManager;
|
||||||
|
|
||||||
public override void AfterAwake()
|
public override void AfterAwake()
|
||||||
{
|
{
|
||||||
agvMap = FindSingle<AGVMap>();
|
agvMap = FindSingle<AGVMap>();
|
||||||
@@ -38,65 +46,128 @@ namespace XED
|
|||||||
agvManager = FindSingle<AGVManager>();
|
agvManager = FindSingle<AGVManager>();
|
||||||
stackerCranes = FindObjectsByType<StackerCrane>(UnityEngine.FindObjectsSortMode.None).ToList();
|
stackerCranes = FindObjectsByType<StackerCrane>(UnityEngine.FindObjectsSortMode.None).ToList();
|
||||||
|
|
||||||
scanningAction += CheckAGVCount;
|
agvNeedScanner = new AGVNeedsScanner(this, agvManager);
|
||||||
scanningAction += CheckStackerSpace;
|
resourceNeedsChecker = new ResourceNeedsScanner(portMap);
|
||||||
scanningAction += CheckStackerInput;
|
stackerNeedsChecker = new StackerCraneNeedsScanner(this, stackerCraneManager);
|
||||||
|
|
||||||
|
scanners.Add(agvNeedScanner);
|
||||||
|
scanners.Add(resourceNeedsChecker);
|
||||||
|
scanners.Add(stackerNeedsChecker);
|
||||||
|
|
||||||
|
agvNeedScanner.onScanningComplete += OnScanningComplete;
|
||||||
|
resourceNeedsChecker.onScanningComplete += OnScanningComplete;
|
||||||
|
stackerNeedsChecker.onScanningComplete += OnScanningComplete;
|
||||||
|
|
||||||
|
Scanning();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckStackerInput()
|
void Scanning()
|
||||||
|
{
|
||||||
|
Debug.Log("Needs Scanning");
|
||||||
|
foreach (var scanner in scanners)
|
||||||
|
{
|
||||||
|
scanner.Scanning();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnScanningComplete(NeedsScanner scanner, List<FactoryNeeds> list)
|
||||||
|
{
|
||||||
|
Debug.Log($"On Needs Scanning Complete {scanner.GetType().Name}");
|
||||||
|
switch (scanner)
|
||||||
|
{
|
||||||
|
case AGVNeedsScanner _:
|
||||||
|
AGVNeedsSolutioning(list);
|
||||||
|
break;
|
||||||
|
case ResourceNeedsScanner _:
|
||||||
|
ResourceNeedsSolutioning(list);
|
||||||
|
break;
|
||||||
|
case StackerCraneNeedsScanner _:
|
||||||
|
StackerNeedsSolutioning(list);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
list.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StackerNeedsSolutioning(List<FactoryNeeds> list)
|
||||||
|
{
|
||||||
|
foreach (var needs in list)
|
||||||
|
{
|
||||||
|
switch (needs)
|
||||||
|
{
|
||||||
|
case FactoryNeeds.StackerInputLoad:
|
||||||
|
DeliveryStackerInputLoad();
|
||||||
|
break;
|
||||||
|
case FactoryNeeds.Stacking:
|
||||||
|
StackerStacking();
|
||||||
|
break;
|
||||||
|
case FactoryNeeds.StackerLoadOut:
|
||||||
|
StackerLoadOut();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StackerLoadOut()
|
||||||
{
|
{
|
||||||
foreach (var stacker in stackerCranes)
|
foreach (var stacker in stackerCranes)
|
||||||
{
|
{
|
||||||
if (!stacker.hasEmptyCell)
|
stacker.AddTask(new OutputTask());
|
||||||
continue;
|
}
|
||||||
|
|
||||||
if (stacker.inputPort.isEmpty)
|
|
||||||
{
|
|
||||||
Debug.Log("Need Stacker Input Load");
|
|
||||||
needs.Add(FactoryNeeds.NeedStackerInputLoad);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"Need Stacker Input");
|
private void ResourceNeedsSolutioning(List<FactoryNeeds> list)
|
||||||
needs.Add(FactoryNeeds.NeedStackerInput);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
{
|
||||||
ScanningVirtualFactory();
|
foreach (var needs in list)
|
||||||
Solutioning();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScanningVirtualFactory()
|
|
||||||
{
|
{
|
||||||
scanningAction?.Invoke();
|
switch (needs)
|
||||||
}
|
|
||||||
|
|
||||||
void Solutioning()
|
|
||||||
{
|
{
|
||||||
foreach(var n in needs)
|
case FactoryNeeds.GenerateLoad:
|
||||||
{
|
GenerateLoad();
|
||||||
switch (n)
|
|
||||||
{
|
|
||||||
case FactoryNeeds.NeedAGV:
|
|
||||||
solutionAction += GenerateAGV;
|
|
||||||
break;
|
|
||||||
case FactoryNeeds.NeedLoad:
|
|
||||||
solutionAction += GenerateLoad;
|
|
||||||
break;
|
|
||||||
case FactoryNeeds.NeedStackerInputLoad:
|
|
||||||
solutionAction += DeliveryStackerInputLoad;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
solutionAction?.Invoke();
|
|
||||||
solutionAction = null;
|
|
||||||
needs.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AGVNeedsSolutioning(List<FactoryNeeds> list)
|
||||||
|
{
|
||||||
|
foreach (var needs in list)
|
||||||
|
{
|
||||||
|
switch (needs)
|
||||||
|
{
|
||||||
|
case FactoryNeeds.GenerateAGV:
|
||||||
|
GenerateAGV();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StackerStacking()
|
||||||
|
{
|
||||||
|
foreach (var stacker in stackerCranes)
|
||||||
|
{
|
||||||
|
if (stackingReadys.Add(stacker) && !stacker.inputPort.isEmpty)
|
||||||
|
{
|
||||||
|
Debug.Log("Stacker Stacking");
|
||||||
|
stacker.onCompleteTask += OnStackerStackingComplete;
|
||||||
|
stacker.AddTask(new InputTask());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStackerStackingComplete(StackerCrane crane)
|
||||||
|
{
|
||||||
|
stackingReadys.Remove(crane);
|
||||||
|
crane.onCompleteTask -= OnStackerStackingComplete;
|
||||||
|
resourceNeedsChecker.Scanning();
|
||||||
|
stackerNeedsChecker.Scanning();
|
||||||
|
}
|
||||||
|
private void OnStackerInputLoad(StackerCrane stacker)
|
||||||
|
{
|
||||||
|
Debug.Log($"Stacker {stacker.name} is On Input Load");
|
||||||
|
stacker.inputPort.onLoadEvent -= () => OnStackerInputLoad(stacker);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void DeliveryStackerInputLoad()
|
private void DeliveryStackerInputLoad()
|
||||||
{
|
{
|
||||||
if (!agvManager.TryGetIdleAGV(out var agvWorker))
|
if (!agvManager.TryGetIdleAGV(out var agvWorker))
|
||||||
@@ -122,6 +193,14 @@ namespace XED
|
|||||||
agvWorker.AddAction(new AGVLoadAction(generatePort));
|
agvWorker.AddAction(new AGVLoadAction(generatePort));
|
||||||
agvWorker.AddAction(new AGVMoveAction(inputLoadPath));
|
agvWorker.AddAction(new AGVMoveAction(inputLoadPath));
|
||||||
agvWorker.AddAction(new AGVUnloadAction(inputPortNode.loader));
|
agvWorker.AddAction(new AGVUnloadAction(inputPortNode.loader));
|
||||||
|
agvWorker.onCompleteTask += OnAGVIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnAGVIdle(AGV worker)
|
||||||
|
{
|
||||||
|
Debug.Log($"{worker.name} is On Enter idle");
|
||||||
|
stackerNeedsChecker.Scanning();
|
||||||
|
worker.onCompleteTask -= OnAGVIdle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateLoad()
|
private void GenerateLoad()
|
||||||
@@ -141,34 +220,5 @@ namespace XED
|
|||||||
var newAGV = agvManager.CreateEmptyAGV();
|
var newAGV = agvManager.CreateEmptyAGV();
|
||||||
newAGV.ForceSet(startNode);
|
newAGV.ForceSet(startNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckStackerSpace()
|
|
||||||
{
|
|
||||||
if (stackerCranes.Sum(sc => sc.cells.Count()) == loads.Count)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var stacker in stackerCranes)
|
|
||||||
{
|
|
||||||
if (stacker.hasEmptyCell)
|
|
||||||
{
|
|
||||||
Debug.Log($"Need Stacker Load");
|
|
||||||
needs.Add(FactoryNeeds.NeedLoad);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckAGVCount()
|
|
||||||
{
|
|
||||||
Debug.Log($"CheckAGVCount");
|
|
||||||
if (maxAGVCount > agvManager.agvs.Count)
|
|
||||||
{
|
|
||||||
needs.Add(FactoryNeeds.NeedAGV);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scanningAction -= CheckAGVCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user