• Not Answered

Msgbox from action in a SFC

Hi!

Using DV Operate, I would like to create message boxes that require the operators to click "ok" to progress to the next step in a SFC. I have the SFC written so that transition points are looking for a variable that I have named "confirmation_#" (# being an assigned number to the step as I have seven confirmation steps) to be a value of "1" in order for the transition to become "true". I have investigated using a "variable object" and adding VBA script to include a message box but there is not a lot in books on line about variable objects. 

Anyone have any experiences or advice for this type of scenario?

Thanks!!

9 Replies

  • Not sure you need a variable, you can just have box, button, etc do like this but I used a YesNo as what if they don't want to do it, you can also do YesNoCancel as well.

    Private Sub ButtonName_Click()
    On Error GoTo ErrorHandler
    If MsgBox("Prompt Message", vbQuestion + vbYesNo, "Prompt Window Title") = vbYes Then
    frsWriteValue "1", "DVSYS.SFC_NAME/CONFIRMATION_#.A_CV"
    End If
    Exit Sub
    ErrorHandler:
    frsHandleError
    End Sub

    If using a single button you would have to read the confirmation number and then use that in the path by concatenating that Integer converted to string in your write path.
  • What is the content of that list of strings? which data it contains??
  • In reply to gamella:

    The VBA code that I've been using is writing values to parameters, but am still having issues with reading values. I thought it may have to do with use of a PLM so I created a parameter in a separate module that I could use to read the status of an action in one of the steps. I had not been using frsReadValue to gain the value so whenever to process got to the first read point, it just sat there. Now that I have added frsReadValue to read the values, I am receiving and "compile" error.

    Does anyone see any issues with:

    Dim Confirm1 As String

    *Code to write values, msg boxes etc. that appears to be working.....

    Confirm1= frsReadValue("DVSYS.MODULE_NAME/TAG.A_CV")
    If Confirm1 = "Complete" Then
    MsgBox, etc..........


    Prior to the change (adding frsReadValue) I was receiving an error (number 438) of "Object doesn't support this property or method".

    Thanks!
  • In reply to Jenny La Bounty:

    Most likely the logic is having an error reading the value. You should try something like this:

    Dim Confirm1 As String
    Dim lngError As Long
    On Error GoTo ErrorHandler
    Confirm1 = frsReadValue("DVSYS.MODULE_NAME/TAG.A_CV", lngError, , false)
    If lngError = 0 Then
    'Value was Read Successfully
    Do your logic using Confirm1

    Else
    'Value Failed to Read Successfully
    Do logic to either ignore read error and do nothing or give a messagebox showing the parameter read error.
    End If
    Exit Sub
    ErrorHandler:
    frsHandleError


    It's been a very long time since I've messed with a PLM but if it isn't Loaded and you are running this logic you may also need to have [_NOT_CONFIG_OK_][_FORCE_READS_] in the path after the A_CV of your path.

    You probably should use StrComp instead of string = string as well to ensure you cover exactly what you want as far as "ABC" = "abc" without having to check all the permutations needed that StrComp can easily do if needed.
  • In reply to Matt Stoner:

    Thank you for your error identification tip! It did help.

    I have not solved the issue yet as I identified where my 438 error was coming from. I had included the VBA code for a timer using "nextchecktime" and "Application.onTime" which I have figured out is not supported in Operate.

    example:
    nextCheckTime = Now + TimeValue("00:00:01")
    Application.OnTime nextCheckTime, "CheckB2"

    So, I am investigating the best path forward. I feel the use of DoEvent is a good idea but I also see warnings about use in books on line about corruption of data so I just need to fully understand the implications of what I am using. After that...back to solving the read issue.
  • In reply to Jenny La Bounty:

    This seems like a separate issue. Maybe it should start a separate thread? If you need to do something repeatedly take a look at Operate's Event Scheduler. I am not sure what you need the HMI to check every second though.

    Edit:  This is in reference to the issue...

    nextCheckTime = Now + TimeValue("00:00:01")
    Application.OnTime nextCheckTime, "CheckB2"

  • I do not see the need for individual CONFIRMATION_#.  A general one should suffice.  Make a boolean parameter named PROCEED and set your transition to DVSYS.SFC_NAME/PROCEED.F_CV

    Also make a boolean parameter named PROCEED_ENAB for the visibility of the Proceed button on the screen.  Be sure to reset PROCEED and PROCEED_ENAB to False at the next step(s) and before the next usage.

    Use Matt Stoner's VBA code on the button and you should be good to go.  I would keep the wording on the popup generic like "Click OK To Proceed".  If you need more specific verbiage, I would use the normal messaging fields on the screen that you are using for every step description.  E.g. "Click OK to Begin Reactor Charge".

  • In reply to Douglas Crowder:

    Thanks for the info Douglas :)

    I have not come across how to impact visibility of buttons within Operate (I know how to in Live but this unit utilizes Operate). I’ve come across how to use a variable object for triggering the visibility of a message box, but am unsure if that’s the right solution. If I understand correctly, if the picture is not open, the message box then would not execute. Due to the length of the sequence, I can imagine the operators may switch back and forth to different pictures during the sequence.
  • In reply to Jenny La Bounty:

    Quick update...I figured out how to adjust the button visibility. I had tried this route before moving on to attempting to manage the button via VBA and should of just kept on pursuing that route. The animation visibility fields for the table are worded oddly in my opinion and sometimes I put too much doubt into myself (ugh). Anyways, I think I am heading down the right path. I appreciate all of you all's advice! Hopefully by the end of the day I have a working solution :)