SmartFarm/SOURCE/PLC_Comm_D13_VCL/fix_modbus.ps1
2026-09-04 10:53:44 +09:00

19 lines
711 B
PowerShell

$filePath = 'c:\Users\MyName\Desktop\PLC_Comm_D13_VCL\uMain.pas'
$lines = Get-Content $filePath -Encoding Default
for ($i = 0; $i -lt $lines.Count; $i++) {
if ($lines[$i] -match 'valve01_ctrl_shm_addr = 24;') {
$lines[$i] = ' valve01_ctrl_shm_addr = 35;'
}
elseif ($lines[$i] -match 'valve01_ctrlSts_shm_addr = 35;') {
$lines[$i] = ' valve01_ctrlSts_shm_addr = 24;'
}
elseif ($lines[$i] -match '19 \+ DONum, 1\)') {
$lines[$i] = $lines[$i] -replace '19', '34'
}
elseif ($lines[$i] -match '19 \+ DONum, 0\);') {
$lines[$i] = $lines[$i] -replace '19', '34'
}
}
Set-Content -Path $filePath -Value $lines -Encoding Default
Write-Host 'Done.'