Author Topic: Boolean Values in Trend ChartWithLogging  (Read 858 times)

aj2004

  • Newbie
  • *
  • Posts: 2
    • View Profile
Boolean Values in Trend ChartWithLogging
« on: June 15, 2021, 01:28:00 PM »
Hello,

The ChartWithLogging Trend Chart works pretty well for me. INTs and REALs plot nicely. However, there are a couple issues I ran into. I searched for a solution and didn't find any posts with this issue. Maybe it's not common to plot things like photoeyes?

BOOLs do not plot at all. The values remain at 0 as shown in the top-left corner (showing the value range). This is because the value is stored as a "true" or "false" string rather than a "1" or "0". I was able to get a value by modifying the "ChartWithLogging.vb" file. Under "Private Sub PolledDataReturnedValue" inside the "While" loop just before the "Catch" condition, "tempValue" has obtained the tag's value of "true" or "false" (or some integer value as a string, but this code just catches boolean values). I added (between the .....):

Code: [Select]
Try
  tempValue = m_PLCAddressValueItems(index).GetScaledValue(e.Values(i))
.....

  If String.Compare(tempValue, "true", True) = 0 Then
    tempValue = CStr(m_PLCAddressValueItems(index).ScaleFactor + m_PLCAddressValueItems(index).ScaleOffset)
  ElseIf String.Compare(tempValue, "false", True) = 0 Then
    tempValue = CStr(m_PLCAddressValueItems(index).ScaleOffset)
  End If

.....
Catch ex As Exception
  tempValue = "," & "INVALID - Check scale factor/offset - " & e.Values(i)
End Try


This will use the "ScaleFactor" and "ScaleOffset" values in the tags list to plot a BOOL between "Offset" and "Offset + Scale".

I haven't looked into it yet, but I think that Integer/Float values are not scaled/offset for this type of Trend Chart. It would be easy enough to add that functionality in.

Maybe there is a better place to put this code. I'm not that great with coding, but this seems to work ok.

File "ChartWithLogging.vb" attached. New code at line 379