skills screen
This commit is contained in:
parent
cac5fad8ce
commit
a920f5fb45
49 changed files with 681 additions and 168 deletions
|
@ -1,8 +1,11 @@
|
|||
import { IsArray, IsOptional, IsString, ValidateNested } from "class-validator";
|
||||
import { IsArray, IsEnum, IsNotEmpty, IsOptional, IsString, ValidateNested } from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
import { ISkillView } from "../../features/behavior_tree_builder/presentation/ui/skill_tree/skill_tree";
|
||||
import { v4 } from "uuid";
|
||||
import { Result } from "../helper/result";
|
||||
import { ValidationModel } from "./validation_model";
|
||||
import { TopicViewModel } from "../../features/topics/topic_view_model";
|
||||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
import clone from "just-clone";
|
||||
|
||||
export interface IDependency {
|
||||
|
@ -18,12 +21,9 @@ export interface ISkill {
|
|||
sid?: string;
|
||||
SkillPackage: ISkillPackage;
|
||||
Module: IModule;
|
||||
Launch: ILaunch;
|
||||
ROS2: IRos2;
|
||||
BTAction: IBTAction[];
|
||||
Interface: IInterface;
|
||||
Settings: ISetting[];
|
||||
xxx: IXxx;
|
||||
// Interface: IInterface;
|
||||
// Settings: ISetting[];
|
||||
}
|
||||
export interface IWeightsDependency {
|
||||
weights_name: string;
|
||||
|
@ -39,16 +39,55 @@ export interface IParam {
|
|||
type: string;
|
||||
dependency: Object;
|
||||
}
|
||||
export class ParamViewModel implements IParam {
|
||||
type: string;
|
||||
dependency: Object;
|
||||
constructor(type: string, dependency: Object) {
|
||||
this.type = type;
|
||||
this.dependency = dependency;
|
||||
}
|
||||
static empty = () => new ParamViewModel("", {});
|
||||
}
|
||||
export interface IBTAction {
|
||||
name: string;
|
||||
format: string;
|
||||
// TODO: Нужно выпилить его отсюда
|
||||
// sid?: string;
|
||||
type: string;
|
||||
param: IParam[];
|
||||
result: string[];
|
||||
}
|
||||
|
||||
export enum BtAction {
|
||||
ACTION = "ACTION",
|
||||
CONDITION = "CONDITION",
|
||||
}
|
||||
export class BtActionViewModel extends ValidationModel implements IBTAction {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name: string;
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
format: string;
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
type: string;
|
||||
param: IParam[];
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
result: string[];
|
||||
@IsNotEmpty()
|
||||
@IsEnum(BtAction)
|
||||
typeAction: BtAction;
|
||||
constructor(name: string, format: string, type: string, param: IParam[], result: string[], typeAction: BtAction) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.format = format;
|
||||
this.type = type;
|
||||
this.param = param;
|
||||
this.result = result;
|
||||
this.typeAction = typeAction;
|
||||
}
|
||||
static empty = () => new BtActionViewModel("", "", "", [], [], BtAction.ACTION);
|
||||
public validParam = (type: string) => this.param.someR((param) => param.type === type);
|
||||
}
|
||||
export interface IInterface {
|
||||
Input: IPut[];
|
||||
Output: IPut[];
|
||||
|
@ -83,19 +122,22 @@ export interface ISkillPackage {
|
|||
format: string;
|
||||
}
|
||||
|
||||
export interface IXxx {
|
||||
cameraLink: string;
|
||||
topicImage: string;
|
||||
topicCameraInfo: string;
|
||||
}
|
||||
|
||||
export class SkillPackage implements ISkillPackage {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name: string;
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
version: string;
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
format: string;
|
||||
constructor(name: string, version: string, format: string) {
|
||||
this.name = name;
|
||||
this.format = format;
|
||||
this.version = version;
|
||||
}
|
||||
static empty = () => new SkillPackage("", "", "");
|
||||
}
|
||||
export class Module implements IModule {
|
||||
@IsString()
|
||||
|
@ -142,12 +184,12 @@ export class Setting implements ISetting {
|
|||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
export class Xxx implements IXxx {
|
||||
cameraLink: string;
|
||||
topicImage: string;
|
||||
topicCameraInfo: string;
|
||||
}
|
||||
export class SkillModel implements ISkill {
|
||||
|
||||
export class SkillModel extends ValidationModel implements ISkill {
|
||||
constructor() {
|
||||
super();
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
sid?: string;
|
||||
|
@ -157,29 +199,12 @@ export class SkillModel implements ISkill {
|
|||
@ValidateNested()
|
||||
@Type(() => Module)
|
||||
Module: IModule;
|
||||
@ValidateNested()
|
||||
@Type(() => Launch)
|
||||
Launch: ILaunch;
|
||||
@ValidateNested()
|
||||
@Type(() => Ros2)
|
||||
ROS2: IRos2;
|
||||
@ValidateNested()
|
||||
@IsArray()
|
||||
@Type(() => BTAction)
|
||||
BTAction: IBTAction[];
|
||||
@ValidateNested()
|
||||
@Type(() => Interface)
|
||||
Interface: IInterface;
|
||||
@ValidateNested()
|
||||
@IsArray()
|
||||
@Type(() => Setting)
|
||||
Settings: ISetting[];
|
||||
@ValidateNested()
|
||||
@Type(() => Xxx)
|
||||
xxx: IXxx;
|
||||
BTAction: BtActionViewModel[];
|
||||
topicsOut: TopicViewModel[] = [];
|
||||
static empty() {
|
||||
const skillModel = new SkillModel();
|
||||
skillModel.BTAction = [];
|
||||
skillModel.SkillPackage = SkillPackage.empty();
|
||||
return skillModel;
|
||||
}
|
||||
public static isEmpty(skill: SkillModel): Result<void, SkillModel> {
|
||||
|
@ -350,12 +375,6 @@ export class Skills {
|
|||
skill.BTAction.forEach((action) => {
|
||||
action.param.forEach((param) => {
|
||||
if (param.type.isEqual(skillType)) {
|
||||
// console.log('SKILL TYPE')
|
||||
// console.log(skillType);
|
||||
// console.log("SID")
|
||||
// console.log(sid)
|
||||
// console.log("DEPENDENCY")
|
||||
// console.log(param.dependency)
|
||||
acc = Object.keys(param.dependency).isNotEmpty();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue