Le lundi 30 novembre 2015 à 04:20 -0800, NotSoRecentConvert a écrit :
> I've written a function which loads a bunch of data and plots
> individual periods where valves are in a certain configuration. My
> function works but I am curious about best methods.
> 
> function
> qcl_valve_plot(Dr::AbstractString,mindate::DateTime,maxdate::DateTime
> ,dt::Dates.Period,col::Symbol,valveLogic::AbstractString)
> 
> ...
> 
> # Valve Zones
> f4 = []
> valveLogic = replace(valveLogic," =="," .==")
> valveLogic = replace(valveLogic,"V","statuses.Valve")
> valveLogic = "find(" * valveLogic * ")"
> f4 = eval(parse(valveLogic))
> 
> statuses is a custom type with four Valve boolean arrays among other
> parameters (Valve1, Valve2, Valve3, Valve4)
> 
> valveLogic is a string, such as "(V3 & !(V1 & V2)) == true". When
> it's properly formatted by the code it looks more like
> "find((statuses.Valve3 & !(statuses.Valve1 & statuses.Valve2)) .==
> true)".
> 
> Is there a better method which still keeps the input pretty simple?
Could you give more details about the goal of this code? Do you really
need to create a string an eval() it?

Regards

Reply via email to