Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as Tabs from '@radix-ui/react-tabs'
import { collectUsedIecAddresses } from '@root/backend/shared/ethercat'
import { useDeviceConfiguration } from '@root/frontend/hooks/use-device-configuration'
Expand Down Expand Up @@ -66,7 +66,7 @@
}, [project.data.remoteDevices, busName])

const configuredDevices = useMemo(() => {
return (remoteDevice?.ethercatConfig?.devices ?? []) as unknown as ConfiguredEtherCATDevice[]
return remoteDevice?.ethercatConfig?.devices ?? []
}, [remoteDevice])

const device = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as Tabs from '@radix-ui/react-tabs'
import { collectUsedIecAddresses } from '@root/backend/shared/ethercat/collect-used-iec-addresses'
import { createDefaultSlaveConfig } from '@root/backend/shared/ethercat/device-config-defaults'
Expand Down Expand Up @@ -98,7 +98,7 @@
}, [project.data.remoteDevices, deviceName])

const configuredDevices = useMemo(() => {
return (remoteDevice?.ethercatConfig?.devices ?? []) as unknown as ConfiguredEtherCATDevice[]
return remoteDevice?.ethercatConfig?.devices ?? []
}, [remoteDevice])

const masterConfig = useMemo(() => {
Expand Down
7 changes: 3 additions & 4 deletions src/frontend/store/slices/project/slice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cycleTimeUsToIecInterval, ethercatTaskName } from '@root/backend/shared/ethercat/ethercat-task-helpers'
import type { EthercatConfig } from '@root/backend/shared/types/PLC/open-plc'
import { produce } from 'immer'
import { StateCreator } from 'zustand'

Expand Down Expand Up @@ -1184,7 +1183,7 @@
)
return ok()
},
updateEthercatConfig: (deviceName: string, ethercatConfig: EthercatConfig | Record<string, unknown>) => {
updateEthercatConfig: (deviceName, ethercatConfig) => {
let response = ok()
setState(
produce((slice: ProjectSlice) => {
Expand All @@ -1201,10 +1200,10 @@
response = { ok: false, message: 'Device is not an EtherCAT device' }
return
}
device.ethercatConfig = ethercatConfig as typeof device.ethercatConfig
device.ethercatConfig = ethercatConfig

// Sync master config fields to the associated system task
const masterCfg = (ethercatConfig as EthercatConfig).masterConfig
const masterCfg = ethercatConfig.masterConfig
if (masterCfg) {
const systemTask = slice.project.data.configurations.resource.tasks.find(
(t) => t.isSystemTask && t.associatedDevice === deviceName,
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/store/slices/project/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
EthercatConfig,
ModbusBufferMapping,
ModbusIOGroup,
OpcUaNodeConfig,
Expand Down Expand Up @@ -239,7 +240,7 @@
) => ProjectResponse
deleteIOGroup: (deviceName: string, groupId: string) => ProjectResponse
updateIOPointAlias: (deviceName: string, groupId: string, pointId: string, alias: string) => ProjectResponse
updateEthercatConfig: (deviceName: string, ethercatConfig: Record<string, unknown>) => ProjectResponse
updateEthercatConfig: (deviceName: string, ethercatConfig: EthercatConfig) => ProjectResponse
}

// ---------------------------------------------------------------------------
Expand Down
37 changes: 17 additions & 20 deletions src/middleware/shared/ports/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/**
* Shared domain types used by port interfaces.
*
Expand All @@ -7,6 +7,8 @@
* implement the ports that use them.
*/

import type { ConfiguredEtherCATDevice } from './esi-types'

// ---------------------------------------------------------------------------
// Result wrappers
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -384,31 +386,26 @@
opcuaServerConfig?: OpcUaServerConfig
}

// EtherCAT
export interface EtherCATMasterConfig {
enabled?: boolean
networkInterface: string
cycleTimeUs: number
watchdogTimeoutCycles?: number
taskPriority?: number
}

export interface EthercatConfig {
masterConfig?: EtherCATMasterConfig
devices: ConfiguredEtherCATDevice[]
}

// PLCRemoteDevice
export interface PLCRemoteDevice {
name: string
protocol: RemoteDeviceProtocol
modbusTcpConfig?: ModbusRemoteTcpConfig
ethercatConfig?: {
masterConfig?: {
enabled?: boolean
networkInterface: string
cycleTimeUs: number
watchdogTimeoutCycles?: number
taskPriority?: number
}
devices: Array<{
id: string
name: string
channelMappings: Array<{
channelId: string
iecLocation: string
userEdited: boolean
alias?: string
}>
[key: string]: unknown
}>
}
ethercatConfig?: EthercatConfig
}

// ---------------------------------------------------------------------------
Expand Down
Loading