Announcement

Collapse
No announcement yet.

How plugin works? need fully understand plugin

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

  • How plugin works? need fully understand plugin

    I have read some plugin source code and also write several simple plugins, but still can not fully understand plugin. So raise my questions here:

    1)RR may load many plugin when it starts, so there are many methods with same name. For example, if has 3 plugins, it will have 3 ProcessCommand method. How does RR handle this(multi-methods with same name)? It will execute each method one by one?

    2) Public Function ProcessCommand(ByVal CMD As String, ByVal frm As Object) As Integer
    It seems that CMD should be defined as ByRef, since it may be modified in the method.

    3)Public Function ReturnLabel(ByVal LBL As String, ByVal FMT As String) As String
    When will the method be called? for example, I write my code in ReturnLabel which will return the label text based on the label code. But It seems that the method was never called. I have to set the label taxt via COM interface:
    RRExtension.SDK.Execute("SETLABEL;PDC_DISTANCE;" & bean.getMinDist())

    4)Public Function ReturnSlider(ByVal SLD As String) As Long
    Originally posted by Enforcer View Post
    ReturnSlider is called from within RoadRunner (as is everything within the RRExtension.cls) at a set period, normally I think every 1/10th second (this can be changed by the user)
    So I set the value in this method. But the sliders(pdc_sensor_a,b,c,d) were not changed. I can not find the set command via COM interface too.

    Code:
        Public Function ReturnSlider(ByVal SLD As String) As Long
    
            'This tells RR that the Slider was not processed in this plugin
            ReturnSlider = -1
    
            Select Case LCase(SLD)
    
                Case "pdc_sensor_a"
                    ReturnSlider = Int(327.68 * statusHolder.getPdcStatusBean.getDistRL1())
                    If ReturnSlider > 65536 Then ReturnSlider = 65536
    
                Case "pdc_sensor_b"
                    ReturnSlider = Int(327.68 * statusHolder.getPdcStatusBean.getDistRL2())
                    If ReturnSlider > 65536 Then ReturnSlider = 65536
    
                Case "pdc_sensor_c"
                    ReturnSlider = Int(327.68 * statusHolder.getPdcStatusBean.getDistRL3())
                    If ReturnSlider > 65536 Then ReturnSlider = 65536
    
                Case "pdc_sensor_d"
                    ReturnSlider = Int(327.68 * statusHolder.getPdcStatusBean.getDistRL4())
                    If ReturnSlider > 65536 Then ReturnSlider = 65536
    
            End Select
    
        End Function

  • #2
    Originally posted by efun View Post
    I have read some plugin source code and also write several simple plugins, but still can not fully understand plugin. So raise my questions here:

    1)RR may load many plugin when it starts, so there are many methods with same name. For example, if has 3 plugins, it will have 3 ProcessCommand method. How does RR handle this(multi-methods with same name)? It will execute each method one by one?

    2) Public Function ProcessCommand(ByVal CMD As String, ByVal frm As Object) As Integer
    It seems that CMD should be defined as ByRef, since it may be modified in the method.

    3)Public Function ReturnLabel(ByVal LBL As String, ByVal FMT As String) As String
    When will the method be called? for example, I write my code in ReturnLabel which will return the label text based on the label code. But It seems that the method was never called. I have to set the label taxt via COM interface:
    RRExtension.SDK.Execute("SETLABEL;PDC_DISTANCE;" & bean.getMinDist())

    4)Public Function ReturnSlider(ByVal SLD As String) As Long
    So I set the value in this method. But the sliders(pdc_sensor_a,b,c,d) were not changed. I can not find the set command via COM interface too.

    Code:
        Public Function ReturnSlider(ByVal SLD As String) As Long
    
            'This tells RR that the Slider was not processed in this plugin
            ReturnSlider = -1
    
            Select Case LCase(SLD)
    
                Case "pdc_sensor_a"
                    ReturnSlider = Int(327.68 * statusHolder.getPdcStatusBean.getDistRL1())
                    If ReturnSlider > 65536 Then ReturnSlider = 65536
    
                Case "pdc_sensor_b"
                    ReturnSlider = Int(327.68 * statusHolder.getPdcStatusBean.getDistRL2())
                    If ReturnSlider > 65536 Then ReturnSlider = 65536
    
                Case "pdc_sensor_c"
                    ReturnSlider = Int(327.68 * statusHolder.getPdcStatusBean.getDistRL3())
                    If ReturnSlider > 65536 Then ReturnSlider = 65536
    
                Case "pdc_sensor_d"
                    ReturnSlider = Int(327.68 * statusHolder.getPdcStatusBean.getDistRL4())
                    If ReturnSlider > 65536 Then ReturnSlider = 65536
    
            End Select
    
        End Function

    1. yes it calls each plugins processcommand one after the other.

    2. It is allowed that the CMD should change in the plugin, so byval is fine.

    3. again labels get called in each plugin one by one. (don't use com interface, just sdk.execute(<etc>) from your plugin.

    4. Make sure sliders are integers (which in your example you have)

    Comment


    • #3
      Originally posted by Enforcer View Post
      1. yes it calls each plugins processcommand one after the other.

      2. It is allowed that the CMD should change in the plugin, so byval is fine.

      3. again labels get called in each plugin one by one. (don't use com interface, just sdk.execute(<etc>) from your plugin.

      4. Make sure sliders are integers (which in your example you have)

      2. ByVal will not return back the modified CMD. The modified comand will not execute based on my test. After chaning to ByRef, the command works well

      3. Yes, I use SDK.execute to set the label text (I may make a misktake between SDK and COM interface). My question is that the ReturnLabel() was never called. I must use SDK.execute("SETLABEL;...") outside of the RRExtension class. So when will the ReturnLabel() be called? Is it useless since I can use SDK.execute?

      4. the sliders are integers. Even I hardcode the value(for example,65535), the sliders were not showed. So how to control the silder from application code?

      Comment


      • #4
        the offical plugin SDK which is included in the LATEST installer

        Public Function ProcessCommand(CMD As String, frm As Object) As Integer

        which is byRef! and thats what it should be

        look in the RRExtension Plugin Examples directory for the latest sdk
        -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


        • #5
          The plugin code you looked at likely was changed to BYVAL by choice so he could change the variable without affecting RR.

          1) RR calls the process command method of each plugin using the object reference of each plugin.

          2) As it's been said, the original code is ByRef

          3) This method will be called whenever RR needs to translate the label codes into text. It will pass you the label code and the format (if any), and if your plugin has that label defined and return its text, then it will show in RR's skin. If the label isn't defined in your plugin, it's likely internal or on another plugin -- otherwise it will show blank.

          4) As long as you define those slider codes in the skin, it should request your plugin for the value of the sliders you defined and set them in the skin.

          Bear in mind none of the above will work if your plugin isn't registered or isn't setup to be loaded by RR (X definition or plugins.txt of some skins).
          Ride Runner RR's Myspace

          "Being happy is not about having what you want, it's about wanting what you have."
          "The best things in life are always free - but that doesn't mean money can't buy you good things."

          Comment


          • #6
            Thanks guino. so how often the plugin will be called? I mean the interval. Based on my observation, the plugin will be called every 2 seconds. It is too long for me. For the label, I can refresh it when need via SDK.execute(SETLABEL;xxx), but how to refresh the silders?

            Comment


            • #7
              Here is guino's suggestion. I have tried and it works very well. The silders was updated every 1/4s and CPU% is under 4%.

              '// Defined in RRExtension class
              Public Shared curForm As Object

              '// The first line in ProcessCommand function
              curForm = frm

              '//Anywhere I want to update the sliders
              If RRExtension.curForm IsNot Nothing Then RRExtension.curForm.updatesliders()


              Everything in the skin refreshes according to the screenrefresh= setting in RR.INI -- the default is every 1 second. Setlabel will force an update to a label at request, however sliders are only updated when the screen refreshes, however it should be possible for you store the current screen form object (passed with processcommand at the execution of EVERY command -- including LOAD commands) basically, you would declare a curform object in the plugin like:

              (Right below "option explicit" or anywhere globally in your project
              Dim CurForm as Object

              Then in ProcessCommand() function:

              (right before "select case"
              set curform = frm

              Then whenever you'd need to update the sliders, you could call (from anywhere): curform.updatesliders

              Bear in mind:
              -I've never tried anything like the above before -- but I don't see why it shouldn't work
              -The more you call setlabel/updatesliders, the higher CPU load you'll generate.. and updatesliders can be very cpu intensive.

              Let me know,
              Guino.

              Comment

              Working...
              X