progress
This commit is contained in:
parent
50822a031d
commit
d8b5018cb2
69 changed files with 3302 additions and 3652 deletions
|
@ -1,5 +1,6 @@
|
|||
export enum StaticFiles {
|
||||
robossembler_assets = "robossembler_assets.json",
|
||||
assets = "/assets/assets.json",
|
||||
parts = '/assets/parts.json'
|
||||
parts = '/assets/parts.json',
|
||||
robots = '/robots/'
|
||||
}
|
||||
|
|
39
server/src/features/scene/create_robot_scenario.ts
Normal file
39
server/src/features/scene/create_robot_scenario.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { CallbackStrategyWithValidationModel, ResponseBase } from "../../core/controllers/http_controller";
|
||||
import { Result } from "../../core/helpers/result";
|
||||
import { RobotModel } from "./robot_model";
|
||||
import { StaticFiles } from "../../core/models/static_files";
|
||||
import { GetServerAddressUseCase } from "../../core/usecases/get_server_address_usecase";
|
||||
import { SearchManyDataBaseModelUseCase } from "../../core/usecases/search_many_database_model_usecase";
|
||||
import { IProjectModel, ProjectDBModel } from "../projects/models/project_model_database_model";
|
||||
import { ExecProcessUseCase } from "../../core/usecases/exec_process_usecase";
|
||||
|
||||
export class CreateRobotScenario extends CallbackStrategyWithValidationModel<RobotModel> {
|
||||
validationModel: RobotModel = new RobotModel();
|
||||
call = async (model: RobotModel): ResponseBase =>
|
||||
(
|
||||
await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(
|
||||
{ isActive: true },
|
||||
"is dont active projects"
|
||||
)
|
||||
).map((projectModel) => {
|
||||
const { rootDir } = projectModel[0];
|
||||
|
||||
return new GetServerAddressUseCase().call().map(async (serverAddress) =>
|
||||
(
|
||||
await new ExecProcessUseCase().call(
|
||||
rootDir,
|
||||
`python3 $PYTHON_ROBOT_BUILDER --path ${projectModel[0].rootDir + StaticFiles.robots} --name ${
|
||||
model.name
|
||||
} --nDOF ${model.nDof} --toolType ${model.toolType}`,
|
||||
""
|
||||
)
|
||||
).map(() =>
|
||||
Result.ok({
|
||||
robotUrl: `${serverAddress}/${
|
||||
rootDir.match(new RegExp(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gm))[0]
|
||||
}${StaticFiles.robots}${model.name}/robot.xml`,
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
12
server/src/features/scene/robot_model.ts
Normal file
12
server/src/features/scene/robot_model.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { IsNotEmpty, IsNumber, IsString } from "class-validator";
|
||||
|
||||
export class RobotModel {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name: string;
|
||||
@IsNumber()
|
||||
nDof: number;
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
toolType: string;
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { CreateRobotScenario } from "./create_robot_scenario";
|
||||
import { SceneDBModel } from "./scene_database_model";
|
||||
import { SceneValidationModel } from "./scene_validation_model";
|
||||
|
||||
|
||||
export class ScenePresentation extends CrudController<SceneValidationModel, typeof SceneDBModel> {
|
||||
constructor() {
|
||||
super({
|
||||
|
@ -9,5 +10,10 @@ export class ScenePresentation extends CrudController<SceneValidationModel, type
|
|||
validationModel: SceneValidationModel,
|
||||
databaseModel: SceneDBModel,
|
||||
});
|
||||
this.subRoutes.push({
|
||||
method: "POST",
|
||||
subUrl: "create/robot",
|
||||
fn: new CreateRobotScenario(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue