edwardewilliams Posted October 9, 2008 Share Posted October 9, 2008 Some quick background before the quesiton: On the app I'm currently working on, we want the customer to have the ability to apply custom calibration formulae to incoming data from a set of soil sensors. The way the systems are built in the field put 4 to 8 sensors at each of a number of measurement stations in a field. So, we do many things based on an array structure like "DataIn[sT][PR]" where 'ST' is the station number and 'PR' is the probe. However, the actual raw inbound data for each probe comes in on individual channels and we currently place those values in the channels with AddValue() as we parse the incoming data strings. What we want to be able to do is to allow the customer the option of applying a custom calibration to each probe at each station to tweak their system for slight variations in soil type over and above the "standard" values we will be including with the package. There are four possible formulas that can be applied to the incoming values. Each formula is a polynomial with 2 to 4 terms. We have a setup page all built so the customer can set the coefficients for each term and store those values for each station and probe. So now, I need a way to apply the chosen formula to the inbound readings. I can't use a channel conversion because they don't work with AddValue() and I can't place a SWITCH or IF statement in the "EVENT" tab of the channel to select a formula. So how would you solve the problem of doing this: If (Formula_Select == 1) MyChannel.AddValue(VAL + (VAL*A[ST][PR]) + (VAL*B[ST][PR]^2) + (VAL*C[ST][PR]^3)) If (Formula_Select == 2) MyChannel.AddValue(a diffferent formula) If (Formula_Select == 3) MyChannel.AddValue(another formula) ...etc endif My current thought is to bring the raw values in to one channel and then use a sequence to do the maths after all acquisition for a cycle is done. But that seems a bit wasteful of channels and gets confusing from a programming standpoint after more than just a couple of stations. Link to comment Share on other sites More sharing options...
This topic is now archived and is closed to further replies.