progress
This commit is contained in:
parent
50822a031d
commit
d8b5018cb2
69 changed files with 3302 additions and 3652 deletions
2478
server/package-lock.json
generated
2478
server/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -24,24 +24,18 @@
|
|||
"eslint": "^8.47.0",
|
||||
"mocha": "latest",
|
||||
"node-watch": "^0.7.4",
|
||||
"nodemon": "^3.0.1",
|
||||
"nyc": "latest",
|
||||
"source-map-support": "latest",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslint": "latest",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.9.0",
|
||||
"axios": "^1.6.2",
|
||||
"babel-register": "^6.26.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.18.2",
|
||||
"express-fileupload": "^1.4.2",
|
||||
"first-di": "^1.0.11",
|
||||
"md5": "^2.3.0",
|
||||
"mongoose": "^7.6.2",
|
||||
"mongoose-autopopulate": "^1.1.0",
|
||||
"pattern-matching-ts": "^2.0.0",
|
||||
|
@ -50,8 +44,6 @@
|
|||
"rimraf": "^5.0.5",
|
||||
"socket.io": "^4.7.2",
|
||||
"socket.io-client": "^4.7.2",
|
||||
"spark-md5": "^3.0.2",
|
||||
"ts-md5": "^1.3.1",
|
||||
"ts-pattern": "^5.1.1",
|
||||
"tsc-watch": "^6.0.4",
|
||||
"uuid": "^9.0.1"
|
||||
|
|
|
@ -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