88from madsci .common .types .node_types import RestNodeConfig
99from madsci .common .types .resource_types import (
1010 Slot ,
11+ Container ,
1112)
1213from madsci .node_module .helpers import action
1314from madsci .node_module .rest_node_module import RestNode
@@ -93,6 +94,8 @@ def init_resource_templates(self) -> None:
9394 description = "Template of a liconic conveyor nest" ,
9495 tags = ["PlateNest" , "ANSI/SLAS" ],
9596 )
97+
98+ # microplate slot template
9699 self .resource_client .create_template (
97100 resource = Slot (
98101 resource_description = "Microplate nest template for inside LiCONiC incubator" ,
@@ -101,15 +104,53 @@ def init_resource_templates(self) -> None:
101104 description = "Template of a liconic microplate nest" ,
102105 tags = ["PlateNest" , "ANSI/SLAS" , "microplate" ],
103106 )
107+
108+ # deep well slot template
104109 self .resource_client .create_template (
105110 resource = Slot (
106- resource_description = "Deepwell nest template for inside LiCONiC incubator" ,
111+ resource_description = "Deep well nest template for inside LiCONiC incubator" ,
107112 ),
108113 template_name = "liconic_deepwell.nest" ,
109114 description = "Template of a liconic deepwell nest" ,
110115 tags = ["PlateNest" , "ANSI/SLAS" , "deepwell" , "microplate" ],
111116 )
112117
118+ # template for the entire liconic container
119+ self .resource_client .create_template (
120+ resource = Container (
121+ resource_description = "Container for all LiCONiC incubator contents" ,
122+ capacity = 4 , # can hold 4 stacks of any type
123+ ),
124+ template_name = "liconic_contents_container" ,
125+ description = "Template for all incubator contents"
126+ )
127+
128+ # microplate stack template
129+ self .resource_client .create_template (
130+ resource = Container (
131+ resource_description = "Microplate stack resource. Holds up to 22 microplates." ,
132+ capacity = 22 ,
133+ attributes = {
134+ "stack_type" : "microplate" ,
135+ }
136+ ),
137+ template_name = "microplate_stack_template" ,
138+ description = "Microplate stack template for the LiCONiC incubator." ,
139+ )
140+
141+ # deep well stack template
142+ self .resource_client .create_template (
143+ resource = Container (
144+ resource_description = "Deep well stack resource. Holds up to 10 deep well plates." ,
145+ capacity = 10 ,
146+ attributes = {
147+ "stack_type" : "deep_well" ,
148+ }
149+ ),
150+ template_name = "deep_well_stack_template" ,
151+ description = "Deep well stack template for the LiCONiC incubator." ,
152+ )
153+
113154 def create_resources (self ) -> None :
114155 """Create resources for the node module."""
115156
@@ -119,16 +160,60 @@ def create_resources(self) -> None:
119160 resource_name = f"{ self .node_definition .node_name } _conveyor.nest" ,
120161 )
121162
163+ # create container resource for all liconic contents
164+ self .liconic_container = self .resource_client .create_resource_from_template (
165+ template_name = "liconic_contents_container" ,
166+ resource_name = "liconic_incubator"
167+ )
168+
122169 # create stack and slot nest resources inside the incubator
123170 for stack in self .inventory_handler .stacks_dict :
124- template_name = "liconic_deepwell.nest" if self .inventory_handler .stacks_dict [stack ] == 10 else "liconic_microplate.nest"
125- for i in range (self .inventory_handler .stacks_dict [stack ]):
126- self .resource_client .create_resource_from_template (
127- template_name = template_name ,
128- resource_name = f"{ self .node_definition .node_name } _stack{ stack } _slot{ i + 1 } .nest" ,
171+ num_stack_nests = self .inventory_handler .stacks_dict [stack ]
172+ stack_template_name = "deep_well_stack_template" if num_stack_nests == 10 else "microplate_stack_template"
173+ nest_type = "deep_well" if num_stack_nests == 10 else "microplate"
174+
175+ print () # TESTING
176+ print (f"STACK{ stack } " ) # TESTING
177+ current_stack = self .resource_client .create_resource_from_template (
178+ template_name = stack_template_name ,
179+ resource_name = f"stack{ stack } " ,
180+ )
181+ self .resource_client .set_child (
182+ resource = self .liconic_container ,
183+ child = current_stack ,
184+ key = stack - 1 ,
185+ )
186+
187+ for i in range (num_stack_nests ):
188+ print (f"slot{ i + 1 } " ) # TESTING
189+ self .resource_client .set_child (
190+ resource = current_stack ,
191+ child = Slot (
192+ resource_name = f"slot{ i + 1 } " ,
193+ resource_description = f"stack{ stack } _slot{ i + 1 } nest resource in LiCONiC incubator" ,
194+ attributes = {
195+ "slot_type" : nest_type
196+ }
197+ ),
198+ key = i
129199 )
130- time .sleep (0.02 ) # slight delay to avoid overwhelming the resource server
131- # TODO: Is there a better way to do this so as to not overwhelm the resource server?
200+ time .sleep (0.02 ) # worst of all possible options
201+ # could turn off rate limiting for the resource manager.
202+
203+
204+ # THIS IS THE MOVE!
205+ # Case 1: there's no existing implementation (new node construct based on xml)
206+ # create resource after initializing all resources
207+
208+ # Case 2: Already exists
209+ # Get the existing version and make changes to it.
210+ # query the whole thing
211+ # make changes locally
212+ # push all back up with update
213+
214+ # NOTE: You can treat the resource items as python objects
215+ # parent.children.append()
216+ # parent.child[0] = the child... etc.
132217
133218 def state_handler (self ) -> None :
134219 """Periodically called to update the current state of the node."""
0 commit comments