Results 1 to 10 of 10

Thread: [RESOLVED] For Loop - Need individual Values

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2022
    Posts
    28

    Re: For Loop - Need individual Values

    Quote Originally Posted by jdc2000 View Post
    Post the code where you are actually defining the values in question.
    Here are the variables listed in the code. I reposted the code here as well.

    Code:
            Public Shared DR_FanShutdown As Boolean
    	Private _oMain As ValuePair
    	Private _ostatus As NameTypePair '(This variable is linked to a Class file that allows an LED light to change color depending on if it's On or Off and allows text to be displayed on the screen)
    	Private _TempOverride As fbInteger '(This variable is much like a normal Integer, only it has other features built into it that allow it to be displayed on the screen at the Settings Edit level & the User can change its value)
    	
    	
    	'==============Other Class File Variables=========
    	Public Shared _FanKill As Boolean = False 'Fans.Base.vb Class File
    	Public m_SetPoint As fbDouble 'Zone.Base.vb Class File
    	Public AvgWTemp As Double 'Zone.Base.vb Class File
    	
    	
    	'==============setup the settings=================
    	_TempOverride = AddInteger(2, "Temp. Override (Turn Fans Back On)", "Temp. Above Setpoint to Turn Fans Back On (Override Everything Else)", 10, 1, PropUse.Advanced, m_Node, "tempoverride", 3)
    	
    	
    	'========setup the Record/View data===========
            _oMain = AddVP(VType.Boolean, True, 0)
            _ostatus = _oMain.AddSub("Status:", VType.String, True, -1, "Off")
            _oCntdwn = _oMain.AddSub("Remaining Time", VType.String, False, -1)
    	
    
    Public Overrides Sub Update()
            MyBase.Update()
    
    For i As Integer = 0 To MyFacility.Count - 1
    
                    Try
                        If MyFacility.List(i).Name = MyEnergyEfficiency.List(0).Items(i).OwnerName Then
                            'If MyFacility.List(i).AvgWTemp < (CInt(MyFacility.List(i).m_SetPoint) + _TempOverride.Value) Then
                            'If (MyFacility.List(i).m_SetPoint.Value + _TempOverride.Value) >= MyFacility.List(i).AvgWTemp Then
                            If MyFacility.List(i).AvgWTemp <= (MyFacility.List(i).m_SetPoint.Value + _TempOverride.Value) Then
                                DR_FanShutdown = True
                                _ostatus.Value = "Fans Shutdown"
                                Fan._FanKill = True
                            Else
                                DR_FanShutdown = False
                                _ostatus.Value = "Temp. Override; Fans On"
                                Fan._FanKill = False
                            End If
                        End If
                    Catch ex As Exception
    
                    End Try
    
                Next
    
    End Sub
    Note: I feel the need to add a little more information since this seems to be a difficult task to figure out & I'm beating my head against the wall on this, so any help is so very much appreciated.

    The values below end up equalling whatever the last zone in the list equals and every zone's fan either turns On or Off (incorrectly when some should be On and some shouldn't).

    DR_FanShutdown's (This is a Normal Boolean that gets sent over to another class file (Public Shared, so that the main controls for this Energy Savings Feature may do other stuff.
    _ostatus.Value (NameTypePair: This variable is linked to a Class file that allows an LED light to change color depending on if it's On or Off and allows text to be displayed on the screen)
    Fan._FanKill (Fan = Class File Name and _FanKill = A normal boolean that has code to turn the zone's fans off if equals True. This must be this way otherwise we'll never be able to turn the fans off, but it too seems to be a blanket value that causes all zones to turn its fans On or Off depending on the last value; for the last zone in the for loop's list).

    The way it normally works is that each zone runs through the class file (Named: DemandResponse; attached to the EnergyEfficiency.Base file).

    I know the code for all 3 files that are linked and the other files we're sending values to work. If I don't use the For Loop and just run the code without it, its output values are correct. Basically the Class file acts as its own For Loop in a way, but once I added this new feature, the variables almost became global, even though the boolean and NameTypePair values are locally defined in the same Class I'm running this code in (I really hope this makes sense to you).

    The problem is that we need to have a feature built in that if the Average Temp. in the Zone is so many degrees above its own Temperature Setpoint, the fans need to come back on (regardless if the DemandResponseControl is saying otherwise; which by the way is initiated by a press of a button & a timer starts (also settable) & once the timer ends, everything will go back to normal eventually (more controls to be added for turning them on in increments to avoid a power surge).
    Last edited by RussellBishopSr; Aug 15th, 2023 at 10:33 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width