index.ts 4.33 KB
import type { CommandCallWayEnum } from '@/enums/commandEnum'
import type { TCPProtocolTypeEnum, TransportTypeEnum } from '@/enums/deviceEnum'
import type { DataTypeEnum, ExtendDescOperationTypeEnum, FunctionTypeEnum, OriginalDataTypeEnum } from '@/enums/objectModelEnum'

export interface DeviceProfileItemType {
  id: string
  creator: string
  createTime: string
  name: string
  description: string
  tenantId: string
  transportType: string
  provisionType: string
  deviceType: string
  tbProfileId: string
  profileData: ProfileData
  type: string
  default: boolean
}

export interface ProfileData {
  configuration: Configuration
  transportConfiguration: TransportConfiguration
  provisionConfiguration: ProvisionConfiguration
  alarms: any
  thingsModel: ThingsModel[]
}

interface AdditionalInfo {
  cmdType: string
}

export interface SendValue {
  additionalInfo: AdditionalInfo
  method: string
  params: Object
  persistent: boolean
}

export interface Configuration {
  type: string
}

export interface TransportConfiguration {
  type: string
  protocol: TCPProtocolTypeEnum
}

export interface ProvisionConfiguration {
  type: string
  provisionDeviceSecret: any
}

export interface StructJSON {
  functionName: string
  identifier: string
  remark?: string
  dataType?: DataType
  serviceCommand?: string
  accessMode?: string
}

export interface ThingsModel {
  functionType: FunctionTypeEnum
  functionName: string
  identifier: string
  callType: any
  accessMode: string
  eventType: any
  functionJson: FunctionJson
  status: number
  deviceProfileId: string
  remark: any
  extensionDesc?: Recordable
}

export interface FunctionJson {
  dataType: DataType
  inputData?: StructJSON[]
  outputData?: StructJSON[]
  serviceCommand?: string
}

export interface OrganizationItemType {
  id: string
  creator: string
  createTime: string
  name: string
  enabled: boolean
  tenantId: string
  parentId: string
  sort: number
  updater?: string
  updateTime?: string
  children: OrganizationItemType[]
}

export interface DeviceItemType {
  id: string
  creator: string
  createTime: string
  updater: string
  updateTime: string
  name: string
  enabled: boolean
  tenantId: string
  deviceInfo: DeviceInfo
  alias: string
  deviceState: string
  profileId: string
  deviceProfileId: string
  gatewayId: string
  tbDeviceId: string
  brand: string
  sn: string
  code: string
  codeType: string
  organizationId: string
  deviceType: string
  alarmStatus: number
  enable: boolean
  deviceProfile: {
    transportType: TransportTypeEnum
    profileData: ProfileData
  }

  transportType: TransportTypeEnum
}

export interface DeviceInfo {
  longitude: number
  latitude: number
  address: string
}

export interface ThingsModelItemType {
  identifier: string
  extensionDesc?: ExtensionDesc
  name: string
  detail: Detail
  accessMode: string
}

export interface ExtensionDesc {
  writeOnly?: boolean
  bitMask?: number
  operationType: ExtendDescOperationTypeEnum
  originalDataType: OriginalDataTypeEnum
  registerAddress: string
  scaling?: number
  valueRange?: Record<'min' | 'max', number>
  registerCount?: number
}

export interface Detail {
  dataType: DataType
}

export interface DataType {
  type: DataTypeEnum
  specs: Specs | StructJSON[]
  specsList: Specs[]
}

export interface Specs {
  valueRange?: ValueRange
  unit?: Unit
  unitName?: string
  boolOpen?: string
  boolClose?: string
  length?: string
  min: string
  max: string
  name?: string
  value?: any
  dataType?: DataTypeEnum
  step?: number
}

export interface ValueRange {
  min: number
  max: number
}

export interface Unit {
  value: string
  label: string
  key: string
}

export interface RpcCommandType {
  additionalInfo: Recordable
  method: string
  params: Recordable | string | number
  persistent: boolean
}

export interface DeviceAttributeItemType {
  key: string
  value: boolean
  lastUpdateTs: number
}

export interface DeviceActiveType {
  key: string
  lastUpdateTs: number
  value: boolean
}

export interface ProductsDetailWithThingsModelType {
  id: string
  name: string
  transportType: string
  deviceType: string
  tsl: Tsl[]
}

export interface Tsl {
  functionName: string
  identifier: string
  accessMode: string
  functionType: FunctionTypeEnum
  callType: CommandCallWayEnum
  specs: {
    dataType: DataType
  }
  extensionDesc?: ExtensionDesc
  inputData?: StructJSON[]
  outputData?: StructJSON[]
}