New to DeltaV Live need code for ToggleDigital Point

Hey guys I am new to DeltaV live and am trying to replicate the ToggleDigitalPoint command that was available in iFix.

What I have is

let RemSw = DLSYS.CondReadA(Dsp.Tag+'/REMOTE_CMD.CV',0)
if (RemSw = 0) {DLSYS.WriteAsync(Dsp.Tag+'/REMOTE_CMD.CV', 1)}
if (RemSw = 1) {DLSYS.WriteAsync(Dsp.Tag+'/REMOTE_CMD.CV', 0)}

Can anybody give me a heads up on how to do this properly.

3 Replies

  • A bit of trial and error but I arrived at a solution that works.

    let CurRemReq = (await DLSYS.ReadAsync (Dsp.Tag+'/REMOTE_CMD.CV')).Value
    DLSYS.WriteAsync(Dsp.Tag+'/REMOTE_CMD.CV', !CurRemReq)
  • In reply to Steve Linehan:

    Appreciate the update! I used your code snipped to build out a yes no confirmation window by extending it a bit. I'll post the code below

    Ben Merryman

  • In DeltaV Live (DeltaV 14.LTS +) you could add some TypeScript code on a Button by selecting "Custom Script" Action under the Basics/Button properties.

    (Note: You could also add a script to another object or group by going to the interaction tab and adding the OnClick interaction.)

    Here is an example script for a GEM Yes No action pop up that will close out with a No response after 20 seconds.

    var response

    var strOnOff

    var valCV= (await DLSYS.ReadAsync(Gem.Tag+'/YOUR_PARAMETER.CV')).Value  // Read in current Value

    valCV == 0 ? strOnOff= "Turn On?" : valCV == 1 ? strOnOff= "Turn Off?" : strOnOff="Error in GEM Tag Assignment. Please contact Engineering" // Write message for popup

    response = await DL.MessageBoxAsync(strOnOff, "Warning!", Constants.MessageBoxButtonType.MB_YESNO,20)  // Popup called

    if(response==Constants.MessageBoxReturn.IDYES)  // Yes Selected

    {

    WriteAsync(Gem.Tag+'/SP_PARAMETER.CV', valCV== 0 ? 1 : valCV== 1 ? 0 : valCV)  // Action dependent on current state

    }

    Note 1: Add a DLSYS. in front of the WriteAsync() function.  The EE365 Forums wouldn't let the post go up with that function written out. 

    Note 2: For a context display replace Gem.Tag w/ Dsp.Tag. For a one off button replace Gem.Tag+' with tag path info. The "Tag" GEM parameter will need to be added and configured on the GEM for this script to work.

    Ben Merryman