Skip to content

Commit

Permalink
adding table with inverter models which don't support QPGSn command e…
Browse files Browse the repository at this point in the history
…ven they can run in parallel mode (#251)

* adding table with inverter models which don't support QPGSn command even they can run in parallel mode

---------

Co-authored-by: Nikolay V. Krasko <nikolay@enapter.com>
  • Loading branch information
nkrasko and nkrasko authored Aug 11, 2023
1 parent 12b8f47 commit fced180
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
3 changes: 3 additions & 0 deletions solar_inverters/mpp_solar/mpp_solar_fw/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ local commands = {
device_protocol = {
command = 'QPI',
},
device_model = {
command = 'QMN',
},
general_parameters = {
command = 'QPIGS',
data = {
Expand Down
1 change: 1 addition & 0 deletions solar_inverters/mpp_solar/mpp_solar_fw/mpp_solar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mpp_solar.baudrate = 2400
mpp_solar.data_bits = 8
mpp_solar.parity = 'N'
mpp_solar.stop_bits = 1
mpp_solar.no_qpgs = { 'VM-3000', 'MKS2-5000' }

function mpp_solar:run_with_cache(name)
if mpp_solar:is_in_cache(name) then
Expand Down
33 changes: 25 additions & 8 deletions solar_inverters/mpp_solar/mpp_solar_fw/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local output_mode = commands.output_mode
local device_warning_status = commands.device_warning_status
local serial_number = commands.serial_number
local priorities = commands.set_priorities
local device_model = commands.device_model

local parser = {}

Expand Down Expand Up @@ -173,14 +174,20 @@ function parser:get_connection_scheme(max_parallel_number)
end

function parser:get_max_parallel_number()
local result, data = mpp_solar:run_with_cache(device_rating_info.command)
if result then
-- enapter.log('device rating info: '..tostring(data))
local max_parallel_number = split(data)[device_rating_info.data.parallel_max_num]
if max_parallel_number == '-' then
return 0
else
return tonumber(max_parallel_number)
local result, data = mpp_solar:run_with_cache(device_model.command)
if result and has_value(mpp_solar.no_qpgs, data) then
enapter.log("Inverter doesn't support parallel mode")
return 0
else
local result, data = mpp_solar:run_with_cache(device_rating_info.command)
if result then
-- enapter.log('device rating info: '..tostring(data))
local max_parallel_number = split(data)[device_rating_info.data.parallel_max_num]
if max_parallel_number == '-' then
return 0
else
return tonumber(max_parallel_number)
end
end
end
end
Expand All @@ -198,4 +205,14 @@ function split(str, sep)
return t
end

function has_value(tab, val)
for _, value in ipairs(tab) do
if value == val then
return true
end
end

return false
end

return parser

0 comments on commit fced180

Please sign in to comment.