Re: Initialization Woes
Posted: Sat Feb 04, 2023 2:53 pm
I haven't started making VM modules yet, but this detailed discussion (as well as other recent discussions) are chock full of amazing insights and tips! Thanks!!
A place to discuss Cherry Audio and Voltage Modular
https://458485.trucktrade.tech/
You are fully right. It's almost impossible to be familiar with all knowledge categories. That's why I'm a member of several forums. I appreciate hints from user to user very much.
Code: Select all
public byte[] GetStateInformation()
{
ByteBuffer buffer = ByteBuffer.allocate( bufferSize );
//
String str = editableTextLabel.GetText();
int strLen = str.length();
byte[] stringBytes = str.getBytes();
buffer.putInt( strLen );
buffer.put( stringBytes );
//
return buffer.array();
}
Code: Select all
public void SetStateInformation(byte[] stateInfo)
{
ByteBuffer buffer = ByteBuffer.wrap(stateInfo);
int strLen = 0;
//
if ( buffer.remaining() >= 4 ) // 4 byte for string length
{
strLen = buffer.getInt(); // string length
if ( buffer.remaining() >= strLen )
{
byte[] strByteArray = new byte[ strLen ];
buffer.get( strByteArray );
String tempString = new String( strByteArray );
editableTextLabel.SetText( tempString );
}
}
}
That was Andrew Macaulay.@seal58: Somebody of the manufacturers in this forum reported problems that occured, when an meanwhile updated module trys to restore from an old version data set. He supposed to save a version number at the beginning of the buffer. That can be used to handle different buffer structures for compatibility.
With GetStateInformation() I gave exact 1106 bytes as readable text back to parent system. That number is not mentioned in a VMD log file.17:05:37.733 saved test mode settings to vtSettings:
17:05:37.733 ****************** Log Test Mode Settings ****************
17:05:37.733 testModuleXPosition = 173
17:05:37.734 testSignalsModuleXPosition = 0
17:05:37.734 test mode polyphony = 8
17:05:37.734 cablesTree has 0 children, 0 properties
17:05:37.735 testSignalsState has 0 children, 10 properties
17:05:37.735 testSignalsExtraInfo has 0 children, 1 properties
17:05:37.735 testModuleState has 0 children, 43 properties
17:05:37.736 1 cabinet trees
17:05:37.736 cabinetsChild 0 has 0 children, 0 properties
17:05:37.736 Sending dmcTestModeSettings from client, 0 cables
17:05:37.737 CInterAppCommChannel::SendMessage: wrote 2236 of 2236 bytes; isOpen=1, part 1 of 2, 2777 bytes total buffer size, segment ID eed9afdab2e846e6b22289523b044700
17:05:37.836 CInterAppCommChannel::run: read 95 of 95 bytes; isOpen=1, 0 ms elapsed
17:05:37.836 Read: received ack for eed9afdab2e846e6b22289523b044700
17:05:37.841 CInterAppCommChannel::SendMessage: wrote 1013 of 1013 bytes; isOpen=1, part 2 of 2, 2777 bytes total buffer size, segment ID ff202f836a474cd1acf53e055069a651
17:05:37.842 CInterAppCommChannel::SendMessage: wrote 72 of 72 bytes; isOpen=1
17:05:37.843 Sending dmcQuitting from client
17:05:37.844 CInterAppCommChannel::SendMessage: wrote 34 of 34 bytes; isOpen=1
17:05:37.850 MIActionmsg: queuedMsgFromMaster
Hi Reid,UrbanCyborg wrote: ↑Thu Mar 23, 2023 1:27 pm Colin, how are you using the DecimalFormatSymbols class? That's buried pretty deeply in the localization library. Are you just assuming that the user's machine will have the correct locale for his country already set, so that initializing this class for the default locale will work, then getting a few properties that might matter from this class for use in input/output routines? Or are you actually doing something more profound with the localization library? This one's going to play hob with my IO routines, which often use regexes; beast to arrange for a regex to vary by locale.
Reid
Code: Select all
// locale fix...
result.replace( ',', '.' );
return result;
Code: Select all
// handle locales that use comma instead of dot for decimal separator...
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
if( dfs.getDecimalSeparator() == ',' )
scan = new Scanner( string.replace( '.', ',' ) ); // convert dot to comma
else
scan = new Scanner( string );