Home

J003 Adding integer samples

Content outdated

We are in the process of migrating all content to impulse version 2.0.

Integer signals are similar to logic signals but focus on the total value, not on its bits (and have no bit width). You may use integer, long and BigInteger values with the integer writer.

Impulse integers are not limited to any bit width. Also arrays of integers are possible.



Interface

The interface contains write functions for all supported data types. Additionally you find renamed wrapper functions for scripting purpose.

units
Domain position as a multiple of its domain base (e.g. domain base=1ms; units = 100; -> domain value = 100ms). Consecutive calls need to pass a value greater or equal.
conflict
If set to true, impulse will use conflict color (usually red) to paint the sample. Meaning of "conflict is use-case depended.
value
The given valuein different formats (integer/long/BigInteger)
public interface IIntegerSamplesWriter extends ISamplesWriter{
   
    boolean write(long units, boolean conflict, int value);    
    boolean write(long units, boolean conflict, long value); 
    boolean write(long units, boolean conflict, BigInteger value);
    boolean write(long units, boolean conflict, Number value);
    boolean write(long units, boolean conflict, int[] value);
    boolean write(long units, boolean conflict, long[] value);
    
    boolean writeInt(long units, boolean conflict, int value);    
    boolean writeLong(long units, boolean conflict, long value); 
    boolean writeBig(long units, boolean conflict, BigInteger value);
    boolean writeIntArray(long units, boolean conflict, int[] value);
    boolean writeIntArgs(long units, boolean conflict, int... value);
    boolean writeLongArray(long units, boolean conflict, long[] value);
    boolean writeLongArgs(long units, boolean conflict, long... value);
}	
Open JavaDoc Reference


Signal definition

Below you find an example of how to create an integer and an integer array signal. The integer array definition requires a signal descriptor with the required array size (2).
// Java (reader derived from IRecordGenerator, ISingleDomainRecordGenerator)
Signal signal1 = addSignal(signals, "Integer1", "An integer", 
	ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);
Signal signal2 = addSignal(signals, "Integer3", "XY", 
	ProcessType.Discrete, SignalType.IntegerArray, 
    new SignalDescriptor(SignalDescriptor.CONTENT_DEFAULT,2,
    ISample.INTEGER_ACCURACY_DEFAULT,ISample.FORMAT_DEFAULT));
// JavaScript (recJs, scripted reader,..)
var signal1 = generator.addSignal(signals, "Integer1", "An integer",
	ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);
    
var signal2 = generator.addSignal(signals, "Integer2", "An integer array", 
	ProcessType.Discrete, SignalType.IntegerArray, 
    new SignalDescriptor(SignalDescriptor.CONTENT_DEFAULT,2,ISample.
    	INTEGER_ACCURACY_DEFAULT,ISample.FORMAT_DEFAULT));


Writing samples

Below some examples of using the writer methods for Java and JavaScript. The JavaDoc reference contains additional examples.
// Java (reader derived from IRecordGenerator, ISingleDomainRecordGenerator)
long value = 44; 
writer1.write(1000L, false, value);  
BigInteger value = new BigInteger(44); 
writer1.write(1000L, false, value);  
int[] value = new long[]{4,5};  // a long array value
writer2.write(1000L,false,value);  
     
// JavaScript (recJs, scripted reader,..)
var value = 44; 
writer1.writeLong(1000, false, value);  
     
var value = new java.math.BigInteger(12); 
writer1.writeBig(1000, false, value);   
var value = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 2);  // an integer array value
value[0] = 5; value[1] = 3;
writer2.writeIntArray(1000,false,value);   
     
writer2.writeIntArgs(1000,false,2,4);   

toem

technical software and tooling

Company

Contact Us

This email address is being protected from spambots. You need JavaScript enabled to view it.