@@ -129,7 +129,39 @@ private async void OnIsarStatus(object? sender, MqttReceivedArgs mqttArgs)
129
129
_updateRobotSemaphore . Release ( ) ;
130
130
_logger . LogDebug ( "Semaphore released after updating robot current mission id" ) ;
131
131
}
132
- MissionScheduling . TriggerRobotAvailable ( new RobotAvailableEventArgs ( robot . Id ) ) ;
132
+ await MissionScheduling . StartNextMissionRunIfSystemIsAvailable ( robot . Id ) ;
133
+ }
134
+ }
135
+
136
+ private async void CreateRobot ( IsarRobotInfoMessage isarRobotInfo , Installation installation )
137
+ {
138
+ _logger . LogInformation (
139
+ "Received message from new ISAR instance '{Id}' with robot name '{Name}'. Adding new robot to database" ,
140
+ isarRobotInfo . IsarId , isarRobotInfo . RobotName ) ;
141
+
142
+ var robotQuery = new CreateRobotQuery
143
+ {
144
+ IsarId = isarRobotInfo . IsarId ,
145
+ Name = isarRobotInfo . RobotName ,
146
+ RobotType = isarRobotInfo . RobotType ,
147
+ SerialNumber = isarRobotInfo . SerialNumber ,
148
+ CurrentInstallationCode = installation . InstallationCode ,
149
+ Documentation = isarRobotInfo . DocumentationQueries ,
150
+ Host = isarRobotInfo . Host ,
151
+ Port = isarRobotInfo . Port ,
152
+ RobotCapabilities = isarRobotInfo . Capabilities ,
153
+ Status = RobotStatus . Available ,
154
+ } ;
155
+
156
+ try
157
+ {
158
+ var newRobot = await RobotService . CreateFromQuery ( robotQuery ) ;
159
+ _logger . LogInformation ( "Added robot '{RobotName}' with ISAR id '{IsarId}' to database" , newRobot . Name , newRobot . IsarId ) ;
160
+ }
161
+ catch ( DbUpdateException )
162
+ {
163
+ _logger . LogError ( $ "Failed to add robot { robotQuery . Name } with to the database") ;
164
+ return ;
133
165
}
134
166
}
135
167
@@ -154,35 +186,7 @@ private async void OnIsarRobotInfo(object? sender, MqttReceivedArgs mqttArgs)
154
186
155
187
if ( robot == null )
156
188
{
157
- _logger . LogInformation (
158
- "Received message from new ISAR instance '{Id}' with robot name '{Name}'. Adding new robot to database" ,
159
- isarRobotInfo . IsarId , isarRobotInfo . RobotName ) ;
160
-
161
- var robotQuery = new CreateRobotQuery
162
- {
163
- IsarId = isarRobotInfo . IsarId ,
164
- Name = isarRobotInfo . RobotName ,
165
- RobotType = isarRobotInfo . RobotType ,
166
- SerialNumber = isarRobotInfo . SerialNumber ,
167
- CurrentInstallationCode = installation . InstallationCode ,
168
- Documentation = isarRobotInfo . DocumentationQueries ,
169
- Host = isarRobotInfo . Host ,
170
- Port = isarRobotInfo . Port ,
171
- RobotCapabilities = isarRobotInfo . Capabilities ,
172
- Status = RobotStatus . Available ,
173
- } ;
174
-
175
- try
176
- {
177
- var newRobot = await RobotService . CreateFromQuery ( robotQuery ) ;
178
- _logger . LogInformation ( "Added robot '{RobotName}' with ISAR id '{IsarId}' to database" , newRobot . Name , newRobot . IsarId ) ;
179
- }
180
- catch ( DbUpdateException )
181
- {
182
- _logger . LogError ( $ "Failed to add robot { robotQuery . Name } with to the database") ;
183
- return ;
184
- }
185
-
189
+ CreateRobot ( isarRobotInfo , installation ) ;
186
190
return ;
187
191
}
188
192
0 commit comments