Announcement

Collapse
No announcement yet.

Need help with C#

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help with C#

    I have a little issue when i use 2 lines between the if an the else .

    Code:
                        for (uint g = 0; g < CTInfo.GetCoreCount; g++)
                        {
                            index = g + (i * CTInfo.GetCoreCount);
                            if (CTInfo.IsDistanceToTjMax)
                                SDK.SetUserVar("RRCORETEMP_CORE_TEMP_" + index, Convert.ToString(CTInfo.GetTemp[index]));
                                SDK.SetUserVar("RRCORETEMP_CORE_LOAD_" + index, Convert.ToString(CTInfo.GetCoreLoad[index]));
                            else
                                SDK.SetUserVar("RRCORETEMP_CORE_INFO_" + index, "Core " + index + ": " + CTInfo.GetTemp[index] + "" + TempType + " , " + CTInfo.GetCoreLoad[index] + "% Load");
                                SDK.SetUserVar("RRCORETEMP_CORE_TEMP_" + index, Convert.ToString(CTInfo.GetTemp[index]));
                        }
    Thanks for your help !!!
    Last edited by pierrotm777; 09-30-2012, 10:36 AM.

  • #2
    You need to use { and } to "group" your code belonging to the if statement. If you skip these brackets then only the first line after the if and the else belongs to the statement.
    Change your code to this and it should work:

    Code:
                        for (uint g = 0; g < CTInfo.GetCoreCount; g++)
                        {
                            index = g + (i * CTInfo.GetCoreCount);
                            if (CTInfo.IsDistanceToTjMax)
                                {
                                      SDK.SetUserVar("RRCORETEMP_CORE_TEMP_" + index, Convert.ToString(CTInfo.GetTemp[index]));
                                      SDK.SetUserVar("RRCORETEMP_CORE_LOAD_" + index, Convert.ToString(CTInfo.GetCoreLoad[index]));
                                }
                            else
                                {
                                     SDK.SetUserVar("RRCORETEMP_CORE_INFO_" + index, "Core " + index + ": " + CTInfo.GetTemp[index] + "" + TempType + " , " + CTInfo.GetCoreLoad[index] + "% Load");
                                     SDK.SetUserVar("RRCORETEMP_CORE_TEMP_" + index, Convert.ToString(CTInfo.GetTemp[index]));
                                }
                       }
    Last edited by Borte; 09-30-2012, 12:08 PM. Reason: Additional info
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

    Comment


    • #3
      any why is that a USERVAR!!!!

      over use of uservars!!!

      if yout plugin uses it, and only your plugin, there is no need to make it a uservar
      -Thanks
      Mitch
      www.rush2112.net

      "Did you test it in carwings??"

      Sun, Come shine my way
      May healing waters bury all my pain
      Wind, Carry me home
      The fabric of reality is tearing apart
      The piece of me that died
      Will return To live again

      Comment


      • #4
        Originally posted by mitchjs View Post
        any why is that a USERVAR!!!!

        over use of uservars!!!

        if yout plugin uses it, and only your plugin, there is no need to make it a uservar
        And what i do to use !
        Last edited by mitchjs; 10-02-2012, 09:24 PM.

        Comment


        • #5
          Thanks Borte

          Comment


          • #6
            I want a label that use a number but i want 0 digit , so i try to use the Math.Round function but without success

            Code:
                            case "rrcoretemp_maxtemp_alarm":
                                s = Convert.ToString(Math.Round((((Convert.ToInt32(CoreTempMax) - 20 - 9) * 10) * 65535) / 20));
                                break;
            An idea ?

            Comment


            • #7
              The Math.Round method has multiple calling options, some of these allowes you to specify how many decimals you want.
              Change your code to this and it it should work:

              Code:
                              case "rrcoretemp_maxtemp_alarm":
                                  s = Convert.ToString(Math.Round((((Convert.ToInt32(CoreTempMax) - 20 - 9) * 10) * 65535) / 20, 0));
                                  break;
              Failure is not an option...
              __________________________________________________ ______________________________
              The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

              Comment


              • #8
                Originally posted by pierrotm777 View Post
                And what i do to use !
                variables

                just not USERVARS... unless there is some reason to, ie the USER needs direct acess to it
                -Thanks
                Mitch
                www.rush2112.net

                "Did you test it in carwings??"

                Sun, Come shine my way
                May healing waters bury all my pain
                Wind, Carry me home
                The fabric of reality is tearing apart
                The piece of me that died
                Will return To live again

                Comment


                • #10
                  Originally posted by Enforcer View Post
                  pierrot, if those variables are just to display the info in a skin, then use the return label to display them. keep them as internal variables till then
                  Ok, i understand better !
                  I try to modify that !
                  I want to use a new thread for the timers ! I know how to do in VB.NET but not in C# !

                  Comment


                  • #11
                    Off the top of my head, I think this might be the fastest way. Just keep in mind this is not thread safe, nor possibly the best implementation...
                    Code:
                    System.Threading.Thread thread = new System.Threading.Thread(addressOf);
                    thread.Start();
                    
                    private void addressOf()
                    {
                    }
                    Current Worklog: TBA - '05 Rav4 (Mobo Dead).
                    www.rav4world.com - Forums for Rav4 owners
                    www.flavorfeasts.com - Cooking website/forums
                    -Basic forums live atm, come contribute!

                    Comment


                    • #12
                      If you use the timer class in System.Threading ( System.Threading.Timer), that will execute on it's own thread. But as mentioned, it's not safe to manipulate the UI directly. System.windows.Forms.Timer executes on the UI thread, so it is safe to make changes to the UI in its methods.

                      Mark

                      Comment


                      • #13
                        I have an issue with my sliders that i can't to move !
                        This is my code:
                        Code:
                                #region Sliders
                                /// <summary>
                        		/// 
                        		/// </summary>
                        		/// <param name="SLD"></param>
                        		/// <returns>-1 for not processed</returns>
                        		public long ReturnSlider(ref string SLD)
                        		{
                                    
                                    switch (SLD.ToLower())
                                    {
                                        // SETTINGS
                                        case "rrcoretemp_updatedelay":
                                            return ((UpdateDelay) * 65535 / DelayMax);
                        
                                        case "rrcoretemp_maxtemp_alarm":
                                            return ((CoreTempAlarm) * 65535 / CoreTempMax);
                        
                                    }
                                    return -1;
                        		}
                        
                                //*****************************************************************
                                //* This Function will be called with requested slider code
                                //* specified at the skin file. Simply return the value of the
                                //* slider to be displayed. Values should range from 0 to 65535.
                                //* It is also possible to intercept/change the slider code before
                                //* it is processed in RideRunner (to overwrite existing codes).
                                //*****************************************************************
                                public long SetSlider(ref string SLD,ref int Value, ref bool Direction)
                                {
                                    return -1;
                                    switch (SLD.ToLower())
                                    {
                                        // SETTINGS
                                        case "rrcoretemp_maxtemp_alarm":
                                            CoreTempAlarm = (Value * CoreTempMax) / 65535;
                        
                                        case "rrcoretemp_updatedelay":
                                            UpdateDelay = (Value * DelayMax) / 65535;
                                    }
                                }
                        Where is my error please ?

                        Comment


                        • #14
                          In the second function, your returning -1 as the first line, thus no other code in the function has a chance to run. Not sure if that's the error/issue causing it not to work. If not, what error are you getting, or what line breaks for debugging?
                          Current Worklog: TBA - '05 Rav4 (Mobo Dead).
                          www.rav4world.com - Forums for Rav4 owners
                          www.flavorfeasts.com - Cooking website/forums
                          -Basic forums live atm, come contribute!

                          Comment


                          • #15
                            In vb.net the sliders are defined as:
                            Code:
                                '*****************************************************************
                                '* This Function will be called with requested slider code
                                '* specified at the skin file. Simply return the value of the
                                '* slider to be displayed. Values should range from 0 to 65536.
                                '* It is also possible to intercept/change the slider code before
                                '* it is processed in RideRunner (to overwrite existing codes).
                                '*****************************************************************
                                Public Function ReturnSlider(ByRef SLD As String) As Integer
                            
                                    'This tells RR that the Slider was not processed in this plugin
                                    ReturnSlider = -1
                            
                                    Select Case LCase(SLD)
                            
                                            ' SETTINGS
                                        Case "rr_p2140_setting_polldelay"
                                            ReturnSlider = Math.Round((TempPluginSettings.PollDelay / 10) * 65535)
                            
                                        Case "rr_p2140_setting_lowvbatt"
                                            ReturnSlider = Math.Round((((TempPluginSettings.LowVbatt - 9) * 10) * 65535) / 20)
                            
                            
                                    End Select
                            
                                End Function
                            
                            
                                '*****************************************************************
                                '* This Function will be called with requested slider code
                                '* specified at the skin file. Simply return the value of the
                                '* slider to be displayed. Values should range from 0 to 65535.
                                '* It is also possible to intercept/change the slider code before
                                '* it is processed in RideRunner (to overwrite existing codes).
                                '*****************************************************************
                                Public Sub SetSlider(ByRef SLD As String, ByRef Value As Integer, ByRef Direction As Boolean)
                            
                                    Select Case LCase(SLD)
                                            ' SETTINGS
                                        Case "rr_p2140_setting_lowvbatt"
                                            TempPluginSettings.LowVbatt = (Math.Round((Value * 20) / 65535) * 0.1) + 9
                            
                                        Case "rr_p2140_setting_polldelay"
                                            TempPluginSettings.PollDelay = Math.Round((Value * 10) / 65535)
                            
                            
                                    End Select
                            
                                End Sub

                            Comment

                            Working...
                            X