update
This commit is contained in:
@@ -599,15 +599,8 @@ function sendReceiveMqttMsg(mqttInstance::mqttClientInstance_v2, receivechannel:
|
|||||||
)::NamedTuple where {T<:Any}
|
)::NamedTuple where {T<:Any}
|
||||||
|
|
||||||
timepass = nothing
|
timepass = nothing
|
||||||
attempts = 0
|
attempts = 1
|
||||||
while attempts <= maxattempt
|
while attempts <= maxattempt
|
||||||
attempts += 1
|
|
||||||
if attempts > 1
|
|
||||||
println("\n<sendReceiveMqttMsg()> attempts $attempts/$maxattempt ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
|
||||||
pprintln(outgoingMsg)
|
|
||||||
println("</sendReceiveMqttMsg()> attempts $attempts/$maxattempt ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
sendMqttMsg(mqttInstance, outgoingMsg)
|
sendMqttMsg(mqttInstance, outgoingMsg)
|
||||||
|
|
||||||
starttime = Dates.now()
|
starttime = Dates.now()
|
||||||
@@ -632,6 +625,12 @@ function sendReceiveMqttMsg(mqttInstance::mqttClientInstance_v2, receivechannel:
|
|||||||
end
|
end
|
||||||
sleep(1)
|
sleep(1)
|
||||||
end
|
end
|
||||||
|
if attempts > 1
|
||||||
|
println("\n<sendReceiveMqttMsg()> attempts $attempts/$maxattempt ", @__FILE__, ":", @__LINE__, " $(Dates.now())")
|
||||||
|
pprintln(outgoingMsg)
|
||||||
|
println("</sendReceiveMqttMsg()> attempts $attempts/$maxattempt ", @__FILE__, ":", @__LINE__, " $(Dates.now())\n")
|
||||||
|
end
|
||||||
|
attempts += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
return (success=false,
|
return (success=false,
|
||||||
|
|||||||
25
src/util.jl
25
src/util.jl
@@ -771,35 +771,30 @@ end
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
detect_keyword(keywords::AbstractVector{String}, text::String) -> Vector{Union{Nothing, String}}
|
detect_keyword(keywords::AbstractVector{String}, text::String) -> Dict{String, Integer}
|
||||||
|
|
||||||
Detects if multiple keywords exist in the text in different case variations (lowercase, uppercase first letter, or all uppercase).
|
Detects and counts occurrences of multiple keywords in the text in different case variations (lowercase, uppercase first letter, or all uppercase).
|
||||||
|
|
||||||
# Arguments:
|
# Arguments:
|
||||||
- `keywords::AbstractVector{String}` Vector of keywords to search for
|
- `keywords::AbstractVector{String}` Vector of keywords to search for
|
||||||
- `text::String` The text to search in
|
- `text::String` The text to search in
|
||||||
|
|
||||||
# Returns:
|
# Returns:
|
||||||
- `Vector{Union{Nothing, String}}` Returns a vector containing the matched keyword variations if found, otherwise nothing for each keyword
|
- `Dict{String, Integer}` Returns a dictionary mapping each keyword to its count in the text (0 if not found)
|
||||||
|
|
||||||
# Examples:
|
# Examples:
|
||||||
```jldoctest
|
```jldoctest
|
||||||
julia> detect_keyword(["test", "error", "case"], "This is a Test case with ERRORS case")
|
julia> detect_keyword(["test", "error", "case"], "This is a Test case with ERRORS case")
|
||||||
2-element Vector{Union{Nothing, String}}:
|
Dict{String, Integer}("test" => 1, "error" => 1, "case" => 2)
|
||||||
"Test"
|
|
||||||
"ERRORS"
|
|
||||||
nothing
|
|
||||||
|
|
||||||
julia> detect_keyword(["warning", "missing"], "Warning: data is complete")
|
julia> detect_keyword(["warning", "missing"], "Warning: data is complete")
|
||||||
2-element Vector{Union{Nothing, String}}:
|
Dict{String, Integer}("warning" => 1, "missing" => 0)
|
||||||
"Warning"
|
|
||||||
nothing
|
|
||||||
```
|
|
||||||
|
|
||||||
# Signature
|
# Signature
|
||||||
"""
|
"""
|
||||||
function detect_keyword(keywords::T, text::String)::Union{Nothing, Dict} where {T<:AbstractVector}
|
function detect_keyword(keywords::T, text::String)::Dict{String, Integer} where {T<:AbstractVector}
|
||||||
kw = Dict{String, Any}()
|
kw = Dict{String, Integer}()
|
||||||
splittext = string.(split(text, " "))
|
splittext = string.(split(text, " "))
|
||||||
# use for loop and detect_keyword function to get the exact variation of each keyword in the text then push to kw list
|
# use for loop and detect_keyword function to get the exact variation of each keyword in the text then push to kw list
|
||||||
for keyword in keywords
|
for keyword in keywords
|
||||||
@@ -808,11 +803,13 @@ function detect_keyword(keywords::T, text::String)::Union{Nothing, Dict} where {
|
|||||||
if total != 0
|
if total != 0
|
||||||
kw[keyword] = total
|
kw[keyword] = total
|
||||||
else
|
else
|
||||||
kw[keyword] = nothing
|
kw[keyword] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return kw
|
return kw
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
detect_keyword(keyword::String, text::String) -> Union{Nothing, String}
|
detect_keyword(keyword::String, text::String) -> Union{Nothing, String}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user