#@tool
#extends Node
#
#@onready var box_spawner: BoxSpawner = $"../BoxSpawner"
#@onready var box_spawner_2: BoxSpawner = $"../BoxSpawner2"
#@onready var box_spawner_3: BoxSpawner = $"../BoxSpawner3"
#@onready var box_spawner_4: BoxSpawner = $"../BoxSpawner4"
#
#var tag_group = "TagGroup0"
#func _ready() -> void:
	#
	#SimulationEvents.simulation_started.connect(_on_simulation_started)
#
#func _on_simulation_started() -> void:
#
	#OIPComms.register_tag(tag_group, "Chute_1.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "Chute_1.CTRL.STS.Jam_At_Full_Sensor", 1)
	#OIPComms.register_tag(tag_group, "Chute_1.CTRL.STS.Full", 1)
	#OIPComms.register_tag(tag_group, "Chute_2.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "Chute_2.CTRL.STS.Jam_At_Full_Sensor", 1)
	#OIPComms.register_tag(tag_group, "Chute_2.CTRL.STS.Full", 1)
	#OIPComms.register_tag(tag_group, "Chute_3.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "Chute_3.CTRL.STS.Jam_At_Full_Sensor", 1)
	#OIPComms.register_tag(tag_group, "Chute_3.CTRL.STS.Full", 1)
	#OIPComms.register_tag(tag_group, "Chute_4.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "Chute_4.CTRL.STS.Jam_At_Full_Sensor", 1)
	#OIPComms.register_tag(tag_group, "Chute_4.CTRL.STS.Full", 1)
	#
#
#func _physics_process(delta: float) -> void:
	#box_spawner.disable = bool( or not OIPComms.read_bit(tag_group,"Chute_1.CTRL.STS.Enabled") or OIPComms.read_bit(tag_group,"Chute_1.CTRL.STS.Full"))
	#box_spawner_2.disable = bool( or not  OIPComms.read_bit(tag_group,"Chute_2.CTRL.STS.Enabled") or OIPComms.read_bit(tag_group,"Chute_2.CTRL.STS.Full"))
	#box_spawner_3.disable = bool( or not  OIPComms.read_bit(tag_group,"Chute_3.CTRL.STS.Enabled") or OIPComms.read_bit(tag_group,"Chute_3.CTRL.STS.Full"))
	#box_spawner_4.disable = bool( or not  OIPComms.read_bit(tag_group,"Chute_4.CTRL.STS.Enabled") or OIPComms.read_bit(tag_group,"Chute_4.CTRL.STS.Full"))
	
	
@tool
extends Node

@onready var box_spawner: BoxSpawner = $"../BoxSpawner"
@onready var box_spawner_2: BoxSpawner = $"../BoxSpawner2"
@onready var box_spawner_3: BoxSpawner = $"../BoxSpawner3"
@onready var box_spawner_4: BoxSpawner = $"../BoxSpawner4"

var tag_group = "TagGroup0"
func _ready() -> void:
	#pass
	SimulationEvents.simulation_started.connect(_on_simulation_started)

func _on_simulation_started() -> void:
	#pass
	#OIPComms.register_tag(tag_group, "D2C_Chute_1.CTRL.STS.Gaylord_Jam_At_Full_Sensor", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_1.CTRL.STS.Full", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_1.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_2.CTRL.STS.Gaylord_Jam_At_Full_Sensor", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_2.CTRL.STS.Full", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_2.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_3.CTRL.STS.Gaylord_Jam_At_Full_Sensor", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_3.CTRL.STS.Full", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_3.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_4.CTRL.STS.Gaylord_Jam_At_Full_Sensor", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_4.CTRL.STS.Full", 1)
	#OIPComms.register_tag(tag_group, "D2C_Chute_4.CTRL.STS.Enabled", 1)
	
	OIPComms.register_tag(tag_group, "Chute_1.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "Chute_1.CTRL.STS.Jam_At_Full_Sensor", 1)
	OIPComms.register_tag(tag_group, "Chute_1.CTRL.STS.Full", 1)
	OIPComms.register_tag(tag_group, "Chute_2.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "Chute_2.CTRL.STS.Jam_At_Full_Sensor", 1)
	OIPComms.register_tag(tag_group, "Chute_2.CTRL.STS.Full", 1)
	OIPComms.register_tag(tag_group, "Chute_3.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "Chute_3.CTRL.STS.Jam_At_Full_Sensor", 1)
	OIPComms.register_tag(tag_group, "Chute_3.CTRL.STS.Full", 1)
	OIPComms.register_tag(tag_group, "Chute_4.CTRL.STS.Enabled", 1)
	#OIPComms.register_tag(tag_group, "Chute_4.CTRL.STS.Jam_At_Full_Sensor", 1)
	OIPComms.register_tag(tag_group, "Chute_4.CTRL.STS.Full", 1)
	OIPComms.register_tag(tag_group, "S011050_JR1.AOI.Jam_At_Sorter", 1)
	

func _physics_process(delta: float) -> void:
	#pass
	#box_spawner.disable = (OIPComms.read_bit(tag_group,"D2C_Chute_1.CTRL.STS.Gaylord_Jam_At_Full_Sensor") or OIPComms.read_bit(tag_group,"D2C_Chute_1.CTRL.STS.Full") or not OIPComms.read_bit(tag_group,"D2C_Chute_1.CTRL.STS.Enabled"))
	#box_spawner_2.disable = (OIPComms.read_bit(tag_group,"D2C_Chute_2.CTRL.STS.Gaylord_Jam_At_Full_Sensor") or OIPComms.read_bit(tag_group,"D2C_Chute_2.CTRL.STS.Full") or not OIPComms.read_bit(tag_group,"D2C_Chute_2.CTRL.STS.Enabled"))
	#box_spawner_3.disable = (OIPComms.read_bit(tag_group,"D2C_Chute_3.CTRL.STS.Gaylord_Jam_At_Full_Sensor") or OIPComms.read_bit(tag_group,"D2C_Chute_3.CTRL.STS.Full") or not OIPComms.read_bit(tag_group,"D2C_Chute_3.CTRL.STS.Enabled"))
	#box_spawner_4.disable = (OIPComms.read_bit(tag_group,"D2C_Chute_4.CTRL.STS.Gaylord_Jam_At_Full_Sensor") or OIPComms.read_bit(tag_group,"D2C_Chute_4.CTRL.STS.Full") or not OIPComms.read_bit(tag_group,"D2C_Chute_4.CTRL.STS.Enabled"))
	
	#print("Jam_At_Full_Sensor ",OIPComms.read_bit(tag_group,"D2C_Chute_1.CTRL.STS.Gaylord_Jam_At_Full_Sensor"))
	#print("Full 100 ",OIPComms.read_bit(tag_group,"D2C_Chute_1.CTRL.STS.Full"))
	#print(box_spawner.disable)# or OIPComms.read_bit(tag_group,"Chute_1.CTRL.STS.Full"))
	box_spawner.disable = bool(not OIPComms.read_bit(tag_group,"Chute_1.CTRL.STS.Enabled") or OIPComms.read_bit(tag_group,"Chute_1.CTRL.STS.Full") or OIPComms.read_bit(tag_group,"S011050_JR1.AOI.Jam_At_Sorter"))
	box_spawner_2.disable = bool(not OIPComms.read_bit(tag_group,"Chute_2.CTRL.STS.Enabled") or OIPComms.read_bit(tag_group,"Chute_2.CTRL.STS.Full") or OIPComms.read_bit(tag_group,"S011050_JR1.AOI.Jam_At_Sorter"))
	box_spawner_3.disable = bool(not OIPComms.read_bit(tag_group,"Chute_3.CTRL.STS.Enabled") or OIPComms.read_bit(tag_group,"Chute_3.CTRL.STS.Full") or OIPComms.read_bit(tag_group,"S011050_JR1.AOI.Jam_At_Sorter"))
	box_spawner_4.disable = bool(not OIPComms.read_bit(tag_group,"Chute_4.CTRL.STS.Enabled") or OIPComms.read_bit(tag_group,"Chute_4.CTRL.STS.Full") or OIPComms.read_bit(tag_group,"S011050_JR1.AOI.Jam_At_Sorter"))
