[kepler-users] Enforcing array subtypes.

Jianwu Wang jianwu at sdsc.edu
Wed Jul 21 15:19:56 PDT 2010


Hi Tom,

     Now it is much clearer. Thanks.

     I think you can add 'portparameter.setTypeEquals(new 
ArrayType(BaseType.INT));' before 'portparameter.setExpression("{1}");' 
to constrain its type. It will make sure the portparameter will only 
have a vector of integer. I just tried this way. If users specify wrong 
values, a dialogue will show up explaining the error.

     It's not on my head how to constrain the port or portparameter to 
have between 1 and 5 value. Maybe you need define a separate Type that 
could only have value between 1 and 5, and replace the above 
BaseType.INT to this type?

Best wishes

Sincerely yours

Jianwu Wang
jianwu at sdsc.edu
http://users.sdsc.edu/~jianwu/

Assistant Project Scientist
Scientific Workflow Automation Technologies (SWAT) Laboratory
San Diego Supercomputer Center
University of California, San Diego
San Diego, CA, U.S.A.


On 7/21/2010 2:28 PM, Thomas M. Parris wrote:
> Jianwu,
>
> Thanks for responding.  As I mentioned, I am writing an actor with a
> portparameter (pp) that has a default value of {1}.  The program can only
> make sense out of a vector of integers.
>
> Examples of valid values for pp include:
> 	{1}
> 	{1,2,3}
> 	{4,6,7,10}
>
> Examples of invalid values for pp include:
> 	{1.0}
> 	{{1,2},{3,4}}
> 	{"A", "B"}
>
> I'd like to enforce this by constraining the type of the pp such that:
> 	o it must be an array
> 	o it must by 1-dimensional
> 	o it must be losslessly castable to an integer value.
>
> While it is not needed for this particular actor, I can also envision
> situations where I would additionally constrain the minimum and maximum
> number of elements in the vector (or perhaps other dimensions).  An example,
> might be a program that sets gain parameters for a 5-channel data recorder.
> In this case, it would be helpful to constrain the port or portparameter to
> have between 1 and 5 values.
>
> I see many of the pieces for what I need to do (some of which have ben
> discovered since I sent my query), but have not yet figured out how to
> string them together.
>
> -- Tom
>
> -----Original Message-----
> From: Jianwu Wang [mailto:jianwu at sdsc.edu]
> Sent: Wednesday, July 21, 2010 5:02 PM
> To: Thomas M. Parris
> Cc: 'Kepler Users'
> Subject: Re: [kepler-users] Enforcing array subtypes.
>
> Hi Thomas,
>
>       Sorry, I don't quite get your question. Would you please explain it
> more using concrete examples?
>
>
> Best wishes
>
> Sincerely yours
>
> Jianwu Wang
> jianwu at sdsc.edu
> http://users.sdsc.edu/~jianwu/
>
> Assistant Project Scientist
> Scientific Workflow Automation Technologies (SWAT) Laboratory
> San Diego Supercomputer Center
> University of California, San Diego
> San Diego, CA, U.S.A.
>
>
> On 7/21/2010 12:32 PM, Thomas M. Parris wrote:
>    
>> Greetings,
>>
>> I'm writing an actor with a PortParameter that is an array with a default
>> value of {1}.  So far so good.
>>
>> Is there a way to ensure that the value is also a vector (1-dimensional as
>> opposed to higher order nesting) and does not exceed integer?  At some
>> point, I could also see wanting to set a minimum and maximum lengths of
>>      
> the
>    
>> vector (but that is not required for now).
>>
>> I know how to do similar things with scalars, but not arrays.
>>
>> While I can set the initial value and type to array with:
>>
>> 	portparameter.setExpression("{1}");
>>
>> I can't seem to fnd a method that would be more specific than that short
>>      
> of
>    
>> testing what I get in the actor and throwing an exception.
>>
>> Many thanks in advance for any help provided,
>> Tom
>> ----------------------------------------------------
>> Thomas M. Parris
>> Vice President
>> ISciences, LLC
>> ----------------------------------------------------
>>
>> _______________________________________________
>> Kepler-users mailing list
>> Kepler-users at kepler-project.org
>> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users
>>
>>      



More information about the Kepler-users mailing list