24.11.2023, 18:14
(This post was last modified: 24.11.2023, 18:16 by nmedalacabeza.)
How could I send a start order from SNMP to the generator set?
Thank you
Thank you
Code:
---Vale para la lectura de varios Dispositivos SNMP de lectura ---------------
if not devices then
require('snmp')
devices = {
{
ip = '192.168.1.33', -- Grupo Electrogeno
mapping = {
{ oid = '1.3.6.1.4.1.41809.1.1.0', addr = '35/1/0' }, --Frecuencia red
{ oid = '1.3.6.1.4.1.41809.1.2.0', addr = '35/1/1' }, --Tensión red entre fases 12
{ oid = '1.3.6.1.4.1.41809.1.3.0', addr = '35/1/2' }, --Tensión red entre fases 23
{ oid = '1.3.6.1.4.1.41809.1.4.0', addr = '35/1/3' }, --Tensión red entre fases 31
{ oid = '1.3.6.1.4.1.41809.1.5.0', addr = '35/1/4' }, --Tensión red fase 1
{ oid = '1.3.6.1.4.1.41809.1.6.0', addr = '35/1/5' }, --Tensión red fase 2
{ oid = '1.3.6.1.4.1.41809.1.7.0', addr = '35/1/6' }, --Tensión red fase 3
{ oid = '1.3.6.1.4.1.41809.1.8.0', addr = '35/1/7' }, --Frecuencia grupo
{ oid = '1.3.6.1.4.1.41809.1.9.0', addr = '35/1/8' }, --Tensión grupo entre fases 12
{ oid = '1.3.6.1.4.1.41809.1.10.0', addr = '35/1/9' }, --Tensión grupo entre fases 23
{ oid = '1.3.6.1.4.1.41809.1.11.0', addr = '35/1/10' }, --Tensión grupo entre fases 31
{ oid = '1.3.6.1.4.1.41809.1.12.0', addr = '35/1/11' }, --Tensión grupo fase 1
{ oid = '1.3.6.1.4.1.41809.1.13.0', addr = '35/1/12' }, --Tensión grupo fase 2
{ oid = '1.3.6.1.4.1.41809.1.14.0', addr = '35/1/13' }, --Tensión grupo fase 3
{ oid = '1.3.6.1.4.1.41809.1.15.0', addr = '35/1/14' }, --Corriente fase 1
{ oid = '1.3.6.1.4.1.41809.1.16.0', addr = '35/1/15' }, --Corriente fase 2
{ oid = '1.3.6.1.4.1.41809.1.17.0', addr = '35/1/16' }, --Corriente fase 3
{ oid = '1.3.6.1.4.1.41809.1.18.0', addr = '35/1/17' }, --flagsCurrent
{ oid = '1.3.6.1.4.1.41809.1.23.0', addr = '35/1/18' }, --Potencia activa
{ oid = '1.3.6.1.4.1.41809.1.24.0', addr = '35/1/19' }, --Potencia aparente
{ oid = '1.3.6.1.4.1.41809.1.25.0', addr = '35/1/20' }, --Potencia reactiva
{ oid = '1.3.6.1.4.1.41809.1.27.0', addr = '35/1/21' }, --Nivel combustible
{ oid = '1.3.6.1.4.1.41809.1.28.0', addr = '35/1/22' }, --Tensión alternador carga batería
{ oid = '1.3.6.1.4.1.41809.1.29.0', addr = '35/1/23' }, --Tensión batería
{ oid = '1.3.6.1.4.1.41809.1.35.0', addr = '35/1/24' }, --totalInstant Power
{ oid = '1.3.6.1.4.1.41809.1.40.0', addr = '35/1/25' }, --totalRunningTime
{ oid = '1.3.6.1.4.1.41809.1.42.0', addr = '35/1/26' }, --successfulStarts
{ oid = '1.3.6.1.4.1.41809.1.43.0', addr = '35/1/27' }, --unsuccessfulStarts
{ oid = '1.3.6.1.4.1.41809.1.45.0', addr = '35/1/28' }, --Contador total energía grupo
{ oid = '1.3.6.1.4.1.41809.1.46.0', addr = '35/1/29' }, --status Estado de la central CEA7 / CEM7 representado en mapa de bits:
--(R G Al Bt B T Mn Au P A) pasar valor de hex (que da ) a bin
--El valor activo indica: hex 518 a bin 1 0 1 0 0 0 1 1 0 0 0
-- EJEMPLO R Al Mn Au
--1. R: Contactor de red cerrado
--2. G: Contactor de grupo cerrado
--3. Al: Alarma activa
--4. Bt: Bomba trasiego
--5. B: Modo Bloqueo
--6. T: Modo Test
--7. Mn: Modo Manual
--8. Au: Modo Automático
--9. P: Motor Parado
--10. M: Motor Arrancado
{ oid = '1.3.6.1.4.1.41809.1.47.0', addr = '35/1/30' }, --alarmBitMapHigh
{ oid = '1.3.6.1.4.1.41809.1.48.0', addr = '35/1/31' }, --alarmBitMapLow
{ oid = '1.3.6.1.4.1.41809.2.52.0', addr = '35/1/32' }, --start stop Grupo Electrogeno
{ oid = '1.3.6.1.4.1.41809.2.53.0', addr = '35/1/33' }, --mode Grupo Electrogeno
}
},
{
ip = '192.168.1.35, --Sai
mapping = {
{ oid = '1.3.6.1.4.1.318.1.1.1.2.1.1.0', addr = '35/0/0' }, -- BatteryStatus
{ oid = '1.3.6.1.4.1.318.1.1.1.2.1.2.0', addr = '35/0/1' }, --BatteryTimeOnBattery
{ oid = '1.3.6.1.4.1.318.1.1.1.2.1.3.0', addr = '35/0/3' }, -- BatteryLastReplaceDate
{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.1.0', addr = '35/0/4' }, --BatteryCapacity
{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.2.0', addr = '35/0/5' }, -- BatteryTemperature
{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.3.0', addr = '35/0/6' }, --BatteryRunTimeRemaining
{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.4.0', addr = '35/0/7' }, -- BatteryReplaceIndicator
{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.7.0', addr = '35/0/8' }, --NominalVoltage
{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.8.0', addr = '35/0/9' }, -- ActualVoltage
{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.9.0', addr = '35/0/10' }, --BatteryCurrent
-- { oid = '1.3.6.1.4.1.318.1.1.1.2.2.17.0', addr = '35/0/11' }, -- BatteryChargerStatus
--{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.21.0', addr = '35/0/12' }, --BatteryRecommendedReplaceDate
--{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.23.0', addr = '35/0/13' }, -- BatteryCondition
--{ oid = '1.3.6.1.4.1.318.1.1.1.2.2.25.0', addr = '35/0/14' }, --BatteryTotalCapacity
{ oid = '1.3.6.1.4.1.318.1.1.1.3.2.1.0', addr = '35/0/15' }, -- InputLineVoltage
{ oid = '1.3.6.1.4.1.318.1.1.1.3.2.4.0', addr = '35/0/16' }, --InputFrequency
--{ oid = '1.3.6.1.4.1.318.1.1.1.3.2.11.0', addr = '35/0/17' }, -- InputTotalApparentPower
--{ oid = '1.3.6.1.4.1.318.1.1.1.3.2.12.0', addr = '35/0/18' }, --InputTotalActivePower
--{ oid = '1.3.6.1.4.1.318.1.1.1.3.2.13.0', addr = '35/0/19' }, -- InputBypassTotalApparentPower
--{ oid = '1.3.6.1.4.1.318.1.1.1.3.2.14.0', addr = '35/0/20' }, --InputBypassTotalActivePower
--{ oid = '1.3.6.1.4.1.318.1.1.1.4.1.3.0', addr = '35/0/21' }, -- SystemStatus
{ oid = '1.3.6.1.4.1.318.1.1.1.11.1.1.0', addr = '35/0/22' }, --StateOutputState
--{ oid = '1.3.6.1.4.1.318.1.1.1.11.1.2.0', addr = '35/0/23' }, --StateAlarmStatusr
}
},
}
end
for _, dev in ipairs(devices) do
local conn, err = snmp.open({
version = snmp.SNMPv1,
community = 'public',
port = dev.port or 161,
peer = dev.ip,
})
if conn then
for _, map in ipairs(dev.mapping) do
local res, err = conn:get(map.oid)
if res and res.value ~= nil then
grp.checkwrite(map.addr, res.value)
else
alert('SNMP read from %s %s failed (%s)', dev.ip, map.oid, tostring(err))
end
end
conn:close()
else
alert('SNMP connection to %s failed (%s)', dev.ip, tostring(err))
end
end