¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Data Type Conversion #simplsharp


 

I'm not following your code completely, but the second parameter of Convert.ToInt16 is the base - default is 10, decimal.? Base 16 would be hexadecimal, and I don't know of anything that uses base 32.


On Wed, Feb 16, 2022 at 7:05 AM <charles@...> wrote:

I am having difficulty understanding datatype conversion from SIMPL# to SIMPL+. Currently, I am trying to parse return data from SIMPL+ using my SIMPL# library. The return data comes into SIMPL# as a SimplSharpString. I parse the string then attempt to convert it to a USHORT so that I can have it come out of my SIMPL+ module as an analog signal. Does anyone know a good resource for understanding datatype conversion between SIMPL# and SIMPL+?

Below are some code snippets:

SIMPL+ Analog Output Definition:
ANALOG_OUTPUT? ? LampHours;


SIMPL+? Analog Output Update:

CALLBACK FUNCTION PJLampHoursDataEventHandler(INTEGER hours)

{

LampHours = hours;

?

}

SIMPL+ Delegate Registration:
RegisterDelegate(myPjClass, PJLampStatusEvent, PJLampHoursDataEventHandler);

Event Definition SIMPL#:
? ? ? ? public delegate void PJLampDataHandler(ushort data);
? ? ? ? public PJLampDataHandler PJLampStatusEvent { set; get; }

Part of my SIMPL# CheckResponse Definition:? ? ? ?
? ? ? ? public void CheckResponse(SimplSharpString data)
? ? ? ? {
? ? ? ? ? ? ? ? else if (data.ToString().Contains(ack))
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ParseReturnData(data);
? ? ? ? ? ? ? ? }

Part of my SIMPL# ParseReturnData:
? ? ? ? public void ParseReturnData(SimplSharpString data)
? ? ? ? {
? ? ? ? ? ? ushort PjLampHours = new ushort();
? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case 3: //Lamp
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? try
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? holder = data.ToString().Substring(3, 1);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //uShortHolder = (ushort)Convert.ToInt32(data.ToString().Substring(3, 1), 16);
?
?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (debug > 0)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CrestronConsole.Print("\n\rtest holder = {0}", holder);
?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //CrestronConsole.Print("\n\rtest uShortholder = {0}", uShortHolder.ToString());
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
?
?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PjLampHours = (ushort)Convert.ToInt16(holder, 32);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //PjLampHours = (ushort)Convert.ToInt16(data.ToString().Substring(3, 1), 32);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //PjLampHours = (ushort)Convert.ToInt32(data.ToString().Substring(3, 1), 16);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PJLampStatusEvent(PjLampHours);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }

SIMPL# Print to Console:
? ? ? ? ? ? ? ? if (debug > 0) CrestronConsole.Print("\n\rCurrent PJ Settings: \n\rPjpowerState: {0}\n\rPjcurrentInput: {1}\n\rPjLampHours: {2}\n\rPjcurrentVolume: {3}", Convert.ToString(PjpowerState), Convert.ToString(PjcurrentInput), Convert.ToString(PjLampHours), Convert.ToString(PjcurrentVolume));

What I am seeing in console:
Current PJ Settings:?
PjpowerState: 0
PjcurrentInput: 0
PjLampHours: 0
PjcurrentVolume: 0
?

Join [email protected] to automatically receive all group messages.