Getting Temperature and Humidity in clsOL2MsgExtendedStatus

drchanix

New Member
Hi,
 
I have a temperature and humidity sensor that is connected to OmniPro II zones.
I don't have a thermostat so using the clsThermostat/clsThermostats objects is not probably an option.
I can handle unsolicited packets from the controller as i have set clsOL2EnableNotifications = true.
What I am looking for is what should I need for the request and the response objects.
I need to read the temperature and humidity of a specific sensor when I click a button.
I have been playing around with clsOL2MsgRequestProperties, clsOL2MsgRequestExtendedStatus, clsOL2MsgStatus and clsOL2MsgExtendedStatus but I can't seem to get the temperature and humidity values from a sensor.
I am using C#.Net as my programming codes.
 
Here is a sample code.
 

private void GetNextAuxStatus(ushort ix)
{
        clsOL2MsgRequestExtendedStatus MSG = new clsOL2MsgRequestExtendedStatus(HAC.Connection);
        MSG.ObjectType = enuObjectType.Auxillary;
        MSG.StartingNumber = ix;
        MSG.EndingNumber = ix;
        HAC.Connection.Send(MSG, HandleUnitStatusesResponse);
}

private void HandleUnitStatusesResponse(clsOmniLinkMessageQueueItem M, byte[] B, bool Timeout)
        {
            if (Timeout)
                return;
            if (InvokeRequired)
                Invoke(new HandleReceivedPacketDelegate(HandleUnitStatusesResponse), new object[] { M, B, Timeout });
            else
            {
                if ((B.Length > 3) && (B[0] == 0x21))
                {
                    switch ((enuOmniLink2MessageType)B[2])
                    {
                        case enuOmniLink2MessageType.EOD:

                            break;
                        case enuOmniLink2MessageType.Properties:

                            break;
                        case enuOmniLink2MessageType.ExtendedStatus:

                            break;
                        default:
                            break;
                    }
                }
            }
        }
 

 
Any help is really appreciated.
Thanks.
 
Well, it's been a long, long time since I dabbled with the OP2 SDK and C#.  I came across the following snippet when reviewing some of my really old code.  It's how I acquire temp/humidity data when handling unsolicited data packets.  I hope it helps you.
 
 
 

case enuOmniLink2MessageType.ExtendedStatus:
                     
                            if (B[2] == 0x3b && B[3] == 0x08)  // Aux Sensor
                            {
                                if (B[6] == 0x09)  // Outdoor Temp  9
                                {
                                    labelOutsideTemperature.Text = clsText.DecodeTemp(B[8], HAC.TempFormat, HAC) + "°";
                                }

                                if (B[6] == 0x1c)  // Basement Temp  28
                                {
                                    labelBasementTemperature.Text = clsText.DecodeTemp(B[8], HAC.TempFormat, HAC) + "°";
                                }

                                if (B[6] == 0x1d)  // Basement humidity  29
                                {
                                    labelBasementHumidity.Text = clsText.DecodeHumidity(B[8], HAC);
                                }
                                if (B[6] == 0x21)  // Outside humidity  33
                                {
                                    labelOutsideHumidity.Text = clsText.DecodeHumidity(B[8], HAC);
                                }

 
 
 
Hi BobS0327,
 
Thanks for the immediate reply.
I already got a solution for the unsolicited packets, but your snippet will help a lot because I am calculating the values differently, though with the same result. Well, yours is simpler than mine and I will definitely opt to yours.
 
Anyway, my problem before was an on-demand request. That is when I will click a button to get the temperature or humidity. It's the other way around the unsolicited packets.
And I did already found a solution to this. This is the best solution for me now.
Basically, what I need is an enuObjectType.Auxillary object for my clsOL2MsgRequestProperties request and for the response I did some experiments below.
Code:
case enuOmniLink2MessageType.Properties:
    clsOL2MsgProperties MSG = new clsOL2MsgProperties(HAC.Connection, B);
    HAC.Units.CopyProperties(MSG);
    HAC.Units.CopyAuxProperties(MSG);
    clsUnit Unt = HAC.Units[MSG.ObjectNumber];
    HAC.Zones.CopyProperties(MSG);
    HAC.Zones.CopyAuxProperties(MSG);
    clsZone zone = HAC.Zones[MSG.ObjectNumber];
 
Back
Top