RSview SE and Visual Basic

SCAN.PLC

Member
Join Date
Oct 2005
Location
scotland
Posts
53
Hi ,

I want to write a value to a tag in RSView SE from Visual Basic.
Tg type is String and integers and is a memeory tag.
if you have any code please post it.

thank yoy.
 
txtRecipe exists in the VB form.
RecipeName is a string in Rsview SE.
ThisDisplay.RecipeName.Value = txtRecipe.Text
ThisDisplay.RecipeName.Download
 
Hi Mark ,

when i compile the above code i get an error.
error is Method or Data member not found.i created the tage in View SE and i am using this string tag in vb code.

i do not have much exp in writng the vb code.
please let me know where i am wrong.
 
RecipeName was a String Input display in the SE.

Post what you have so far and we can help you.

txtRecipe was just a input text field in the VB. You
then add a Download button in the VB and call the following

Private Sub cmdDownload_Click()
On Error GoTo LogError

ThisDisplay.RecipeName.Value = txtRecipe.Text
ThisDisplay.RecipeName.Download

Exit Sub
LogError:
LogMessage "Unable to set Value for downloading", cliActivitySeverityError, cliActivityCategoryCommunication


End Sub
 
Tags in RSView

I do not want to take this thread off topic so if I do I will start a new one. I have a general question about tags in RSView VBA. It appears that you cannot use HMI tags (typically linked to PLC tags) directly in RSView's version of VB. Typically you need to use the following code:
Dim oGroup As TagGroup
Dim 0Tag As Tag
Dim vValue as String
oGroup.Add "Real HMI Tag"
Set oTag = oGroup.Item("Real HMI Tag")
vValue = oTag.Value

This seems like a lot of work to set an HMI tag in VB. In other HMI programs with VB capability such as iFix or InteractX, there is a means to set HMI tags directly in VB code. Is there an easier way in RSView? Thanks.
 
Here is the screen shot of vb code error i get.
I have cross checked the tag name in SE and in VB there is no spelling mistake .
 
Well, that is writing directly to the tag. Those are just the steps you need, as the tags are part of the RSView SE Object model... Use the framework, play within it's rules.

The procedure for writing a value to a TAG is similar, with some changes...

DIM HMIGlobalTagGroup as TagGroup ' Declare a tag roup
DIM WorkingTag as Tag ' Declare a working tag register
DIM TagsInError as StringList ' reserve space for error checks
Dim Results as Boolean ' reserve space for error checks
DIM TagName as String ' Convenient, but not needed
TagName = "::[My_PLC5]N7:20" ' Example direct referenced I/O Tag

' Now, to use it...
HMIGlobalTagGroup.Add(TagName) ' The group must contain the tags in use...
TagName = "[Logix_PLC]Scales.Raw.Act_Weight"
HMIGlobalTagGroup.Add(TagName) ' Add another to group, just because

'Read a value from the PLC5...
DIM MyValue as INT
TagName = "::[My_PLC5]N7:20"

Set WorkingTag = HMIGlobalTagGroup(TagName) ' Get plc5 tag from collection
MyValue = WorkingTag.Value ' Get it's value

'Write a value to the Logix..
TagName = "[Logix_PLC]Scales.Raw.Act_Weight"
Set WorkingTag = HMIGlobalTagGroup(TagName)
WorkingTag.PendingWriteValue = 12345
Results = HMIGlobalTagGroup.WritePendingValues(TagsInError)

Cumbersome? perhaps, but it also allows for block writes to the PLC(s). Imagine downloading a recipe to a PLC, the recipe might contain 50 items, by putting them all in a tag group, and assigning values, they all get written when they get the 'WritePendingValues' command on the group.


infineum said:
I do not want to take this thread off topic so if I do I will start a new one. I have a general question about tags in RSView VBA. It appears that you cannot use HMI tags (typically linked to PLC tags) directly in RSView's version of VB. Typically you need to use the following code:
Dim oGroup As TagGroup
Dim 0Tag As Tag
Dim vValue as String
oGroup.Add "Real HMI Tag"
Set oTag = oGroup.Item("Real HMI Tag")
vValue = oTag.Value

This seems like a lot of work to set an HMI tag in VB. In other HMI programs with VB capability such as iFix or InteractX, there is a means to set HMI tags directly in VB code. Is there an easier way in RSView? Thanks.
 
read tags with VBA, from my PLC 5/05 and Factorytalk SE HMI

hi, i cannot get my head around this problem.

i keep getting a Variable not defined error when executing my VB code. ( see images and the vb code below)

i toke an old project built on RS View32 and import it into FactoryTalk View Studio SE. the FT parts works, but the VBA code dont. i modified the code to read tags from the old VBA, as described in the ''KB 51770 Lab Manual - VBA Converting RSView32.pdf'' here's my code and i attached images.

thanks a lot in advance for helping me out.

I wlll be posting a second tread for the rest of my code.

the project code starts here :

ThisDisplay:

Option Explicit
Dim gpGroup As TagGroup



Private Sub Button1_Released()



End Sub

Private Sub Button5_Released()

End Sub

Private Sub Button12_Released()

frmPartsLoad.Show

End Sub


Public Sub Display_AnimationStart()

Set gpGroup = Application.CreateTagGroup(Me.AreaName, 500)
' Set gpGroup = Application.CreateTagGroup(Me.AreaName)

gpGroup.Add "BATCH"

gpGroup.Add "VBA\BATCH"
gpGroup.Add "VBA\START_TIME"
gpGroup.Add "VBA\START_TIME_RSVIEW"
gpGroup.Add "VBA\END_TIME"
gpGroup.Add "VBA\END_TIME_RSVIEW"
gpGroup.Add "VBA\DURATION"

gpGroup.Add "VBA\RECIPE_NO" = ""
gpGroup.Add "VBA\RECIPE_NAME" = ""
gpGroup.Add "VBA\ENCHAINEMENT_NO" = ""
gpGroup.Add "VBA\ENCHAINEMENT_NAME" = ""

gpGroup.Add "ACTIVATION\INIT"
gpGroup.Add "RSVIEW_ENTER"
gpGroup.Add "COMMIT_LOAD"
gpGroup.Add "CYCLE_EN_COURS"

gpGroup.Add "VBA\SourceForTR1"
gpGroup.Add "VBA\SourceForTR2"
gpGroup.Add "VBA\SourceForTR3"
gpGroup.Add "VBA\SourceForTR4"
gpGroup.Add "VBA\SourceForTR5"
gpGroup.Add "VBA\SourceForTR6"
gpGroup.Add "VBA\SourceForTR7"
gpGroup.Add "VBA\SourceForTR8"

gpGroup.Add "VALIDATION\TR\TR_1"
gpGroup.Add "VALIDATION\TR\TR_2"
gpGroup.Add "VALIDATION\TR\TR_3"
gpGroup.Add "VALIDATION\TR\TR_4"
gpGroup.Add "VALIDATION\TR\TR_5"
gpGroup.Add "VALIDATION\TR\TR_6"
gpGroup.Add "VALIDATION\TR\TR_7"
gpGroup.Add "VALIDATION\TR\TR_8"


gpGroup.Add "MinRamp_Rate_TOL"
gpGroup.Add "MaxRamp_Rate_TOL"
gpGroup.Add "Min_Soak_Lim"
gpGroup.Add "Max_Soak_Lim"
gpGroup.Add "LoTemp_Mode_SP"
gpGroup.Add "TEMP_THRESHOLD"
gpGroup.Add "LoTemp_Mode_CMD-Bit"

gpGroup.Add "SEGMENTS_REC1"
gpGroup.Add "SEGMENTS_REC2"

gpGroup.Add "RECIPE\REC1\R1RMP1"
gpGroup.Add "RECIPE\REC1\R1RMP2"
gpGroup.Add "RECIPE\REC1\R1RMP3"
gpGroup.Add "RECIPE\REC1\R1RMP4"
gpGroup.Add "RECIPE\REC1\R1RMP5"
gpGroup.Add "RECIPE\REC1\R1RMP6"
gpGroup.Add "RECIPE\REC1\R1RMP7"
gpGroup.Add "RECIPE\REC1\R1RMP8"
gpGroup.Add "RECIPE\REC1\R1SO1"
gpGroup.Add "RECIPE\REC1\R1SO2"
gpGroup.Add "RECIPE\REC1\R1SO3"
gpGroup.Add "RECIPE\REC1\R1SO4"
gpGroup.Add "RECIPE\REC1\R1SO5"
gpGroup.Add "RECIPE\REC1\R1SO6"
gpGroup.Add "RECIPE\REC1\R1SO7"
gpGroup.Add "RECIPE\REC1\R1SO8"
gpGroup.Add "RECIPE\REC1\R1SP1"
gpGroup.Add "RECIPE\REC1\R1SP2"
gpGroup.Add "RECIPE\REC1\R1SP3"
gpGroup.Add "RECIPE\REC1\R1SP4"
gpGroup.Add "RECIPE\REC1\R1SP5"
gpGroup.Add "RECIPE\REC1\R1SP6"
gpGroup.Add "RECIPE\REC1\R1SP7"
gpGroup.Add "RECIPE\REC1\R1SP8"

gpGroup.Add "RECIPE\REC2\R1RMP1"
gpGroup.Add "RECIPE\REC2\R1RMP2"
gpGroup.Add "RECIPE\REC2\R1RMP3"
gpGroup.Add "RECIPE\REC2\R1RMP4"
gpGroup.Add "RECIPE\REC2\R1RMP5"
gpGroup.Add "RECIPE\REC2\R1RMP6"
gpGroup.Add "RECIPE\REC2\R1RMP7"
gpGroup.Add "RECIPE\REC2\R1RMP8"
gpGroup.Add "RECIPE\REC2\R1SO1"
gpGroup.Add "RECIPE\REC2\R1SO2"
gpGroup.Add "RECIPE\REC2\R1SO3"
gpGroup.Add "RECIPE\REC2\R1SO4"
gpGroup.Add "RECIPE\REC2\R1SO5"
gpGroup.Add "RECIPE\REC2\R1SO6"
gpGroup.Add "RECIPE\REC2\R1SO7"
gpGroup.Add "RECIPE\REC2\R1SO8"
gpGroup.Add "RECIPE\REC2\R1SP1"
gpGroup.Add "RECIPE\REC2\R1SP2"
gpGroup.Add "RECIPE\REC2\R1SP3"
gpGroup.Add "RECIPE\REC2\R1SP4"
gpGroup.Add "RECIPE\REC2\R1SP5"
gpGroup.Add "RECIPE\REC2\R1SP6"
gpGroup.Add "RECIPE\REC2\R1SP7"
gpGroup.Add "RECIPE\REC2\R1SP8"

gpGroup.Active = True

End Sub




'**************************************************************************************
'* Name : RecipeLoad *
'* Description : This function show the RecipeLoad form. *
'**************************************************************************************
Function RecipeLoad()
frmRecipeLoad.Show

End Function
'**************************************************************************************
'* Name : StartDataLog *
'* Description : This function starts the datalogging and creates a new datalog file. *
'* This function is called when the CYCLE_EN_COURS tag value is changed *
'* to ON. *
'**************************************************************************************
Function StartDataLog()


'Put the start time into a memory tag
gpGroup.Item("VBA\START_TIME") = Format(Now, "yyyy-mm-dd hh:mm:ss")
gpGroup.Item("VBA\START_TIME_RSVIEW") = Format(Now, "yyyy-mmm-dd hh:mm:ss")
gpGroup.Item("VBA\END_TIME") = ""
gpGroup.Item("VBA\END_TIME_RSVIEW") = ""
gpGroup.Item("VBA\DURATION") = ""

'Put the datalog ON before creating a new datalog file


ExecuteCommand ("DataLogOn ACTIVE THERMOCOUPLES")
ExecuteCommand ("DataLogOn ACTIVE TRANSDUCERS")
ExecuteCommand ("DataLogOn ACTIVE CURE")
ExecuteCommand ("DataLogOn ALARMS ACTIVE CURE")
ExecuteCommand ("DataLogOn PARTS PRESSURE")
ExecuteCommand ("DataLogOn PARTS TEMPERATURE")
ExecuteCommand ("DataLogOn OVEN TEMP")
' OVEN TEMP added (21/12/07) for realtime trend monitoring in RSView32 HMI
'Create a new datalog file for the new cure
ExecuteCommand ("DataLogNewFile ACTIVE THERMOCOUPLES")
ExecuteCommand ("DataLogNewFile ACTIVE TRANSDUCERS")
ExecuteCommand ("DataLogNewFile ACTIVE CURE")
ExecuteCommand ("DataLogNewFile ALARMS ACTIVE CURE")
ExecuteCommand ("DataLogNewFile PARTS PRESSURE")
ExecuteCommand ("DataLogNewFile PARTS TEMPERATURE")
ExecuteCommand ("DataLogNewFile OVEN TEMP")
' OVEN TEMP added (21/12/07) for realtime trend monitoring in RSView32 HMI

End Function
'**************************************************************************************
'* Name : StopDataLog *
'* Description : This function stops the datalogging. *
'* This function is called when the CYCLE_EN_COURS tag value is changed *
'* to OFF. *
'**************************************************************************************
Function StopDataLog()
'Put the end time into a memory tag
gpGroup.Item("VBA\END_TIME") = Format(Now, "yyyy-mm-dd hh:mm:ss")
If Len(gpGroup.Item("VBA\START_TIME_RSVIEW")) > 1 Then
gpGroup.Item("VBA\END_TIME_RSVIEW") = Format(Now, "yyyy-mmm-dd hh:mm:ss")
gpGroup.Item("VBA\DURATION") = Format(frmPartsLoad.TimeDiff(gpGroup.Item("VBA\START_TIME"), gpGroup.Item("VBA\END_TIME")), "hh:mm:ss")
End If
'Stop the datalog, because this function is called when the cure is finished
ExecuteCommand ("DataLogOff ACTIVE THERMOCOUPLES")
ExecuteCommand ("DataLogOff ACTIVE TRANSDUCERS")
ExecuteCommand ("DataLogOff ACTIVE CURE")
ExecuteCommand ("DataLogOff ALARMS ACTIVE CURE")
ExecuteCommand ("DataLogOff PARTS PRESSURE")
ExecuteCommand ("DataLogOff PARTS TEMPERATURE")
ExecuteCommand ("DataLogOff OVEN TEMP")
' OVEN TEMP added (21/12/07) for realtime trend monitoring in RSView32 HMI
End Function




Private Sub Display_BeforeAnimationStop()

' gpGroup.RemoveAll
Set gpGroup = Nothing

End Sub

Private Sub Display_Click()

End Sub

Private Sub Display_Load()

End Sub

tags.jpg err1.jpg
 
the second part of my code.

frmNewCure:




Option Explicit

'Dim gpGroup As TagGroup
Dim beforeBatch As String
Dim beforeBatchPath As String




'//////////////////////////////////////////////////////////////////////////////////////
'//
'//
'// OBJECTS
'//
'//
'**************************************************************************************
'* ObjectName : UserForm *
'* Event : Initialize *
'* Description : On the form opening, if there's no batch, the user can only create a *
'* new one. If there's one, the user can create a new one, or continue *
'* the current one. *
'**************************************************************************************
Private Sub UserForm_Initialize()

If Batch = "" Then
'Continue cure isn't enabled
optContinueCure.Enabled = False
'User can only create a new batch
optNewCure.value = True

Me.txtBatch.Text = "A0_" & Year(Now) & "_0000_0"
Else
beforeBatch = Batch
beforeBatchPath = BatchPath
'Continue cure or create new cure are enabled
optContinueCure.Enabled = True
optNewCure.Enabled = True
End If
End Sub
'**************************************************************************************
'* ObjectName : cmdCancel *
'* Event : Click *
'* Description : When the user clicks on this button, it closes the form, and nothing *
'* is saved. *
'**************************************************************************************
Private Sub cmdCancel_Click()
Unload Me
End Sub
'**************************************************************************************
'* ObjectName : cmdOk *
'* Event : Click *
'* Description : When the user clicks on this button, we check if the batch number is *
'* a valid one. It must have the following format : A0_year_0000_0. *
'* So if the batch number is a valid one and not already existing we *
'* create a new batch but there's two different new batch : *
'* - An empty one (with the newCure option) *
'* For this option, we create a new batchpath with nothing inside*
'* - Continue the current cure (with the continuCure option) *
'* For this option, we copy the data into the current BatchPath *
'* and copy into the new BatchPath. We also have to put the *
'* datalog file for the current cure in the curent cure batchpath*
'* if not already done. (PAS CODER ENCORE ..) *
'**************************************************************************************
Public Sub cmdOk_Click()
Dim conDBBatch As New ADODB.Connection
Dim strSelectPartsQuery As String
Dim strCreateDBQuery As String
Dim blnValidBatch As Boolean
Dim src, dest As String

blnValidBatch = False


'batch must contain A0_year
If optContinueCure.value = True Then
Batch = Me.lblBatch.Caption

blnValidBatch = True
ElseIf Len(Me.txtBatch.Text) > 8 And Left(Me.txtBatch.Text, 8) = "A0_" & Year(Now) & "_" Then
'Mettre le batch number dans batch
Batch = Me.txtBatch.Text
blnValidBatch = True
Else
MsgBox MSG_ERR_INVALID_BATCH_NUMBER, vbInformation, APPTITLE
End If

If blnValidBatch Then
'Update batch path value
BatchPath = OVEN_DATA_PATH & "\" & DATA_FOLDER & "\" & Batch & LOG_EXT
'Display the new batch number in the parts load form
frmPartsLoad.lblBatch.Caption = "Batch : " & Batch


'Update the rsview memory tags

gpGroup.Item("VBA\BATCH") = Batch
gpGroup.Item("VBA\START_TIME") = ""
gpGroup.Item("VBA\END_TIME") = ""
gpGroup.Item("VBA\DURATION") = ""
'If the batch path doesn't exist, we create it
If Dir(BatchPath, vbDirectory) = "" Then
'Create the new path for this cure
MkDir BatchPath
'Save the batch in the db (AllBatch.dbf)
AddBatchToAllBatchDB (Batch)
If Me.optContinueCure.value = True Then
'Copy the parts files from the privous batch
'Set source directory string
src = beforeBatchPath & "\" & PART_FILENAME & ".DBF"
'Set destination directory string
dest = BatchPath & "\" & PART_FILENAME & ".DBF"
'Copy the file
FileCopy src, dest
'Save the save recipes for that cure
frmPartsLoad.SaveBatchParam "RECIPENB", gpGroup.Item("VBA\RECIPE_NO")
frmPartsLoad.SaveBatchParam "CHAIN", gpGroup.Item("VBA\ENCHAINEMENT_NO")
Else
strCreateDBQuery = "CREATE TABLE `" & PART_FILENAME & "` (partNb varchar(20),travelerNb varchar(14), " & _
"operation varchar(10), TCs varchar(30), TRs varchar(8), source varchar(30));"
'Create ADO connection
'We need to give the folder name where tables are saved --> C:\slc977\Data\'batch'.log
conDBBatch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & BatchPath & ";Extended Properties=DBASE IV"
'Create the .dbf file
conDBBatch.Execute strCreateDBQuery
'Clear the screen
frmPartsLoad.ClearParts
'Close the ADO connection
conDBBatch.Close
'Clear the recipe memory tags
gpGroup.Item("VBA\RECIPE_NO") = ""
gpGroup.Item("VBA\RECIPE_NAME") = ""
gpGroup.Item("VBA\ENCHAINEMENT_NO") = ""
gpGroup.Item("VBA\ENCHAINEMENT_NAME") = ""
'Clear the recipe fields
frmPartsLoad.txtRecipe.Text = ""
frmPartsLoad.txtEnchainement.Text = ""
frmPartsLoad.FillCboRecipe
frmPartsLoad.FillCboEnchainement
End If

'Put the Part Load form in offline status
status = OFFLINE_STATUS
frmPartsLoad.EnabledInput
frmPartsLoad.cmdOfflineLoad.value = True
'COMMIT_LOAD_TAG = OFF
gpGroup.Item("COMMIT_LOAD") = OFF_BIT
'Close this form
Unload Me
Else 'If the batch path already exist, this batch number can't be used another time so the user is informed by a message
MsgBox MSG_ERR_BATCH_NUMBER_ALREADY_USED, vbExclamation, APPTITLE
End If
End If
End Sub
'**************************************************************************************
'* ObjectName : optContinueCure *
'* Event : Click *
'* Description : When the user clicks on this option a new batch number is displayed. *
'* This new batch number replaces the current one and adds 1 to the last*
'* digit. *
'**************************************************************************************
Private Sub optContinueCure_Click()
Dim pos As Integer
'Takes the position of the last '_' in the batch number
pos = InStr(9, Batch, "_")
'Display the new batch number
Me.lblBatch.Caption = Left(Batch, pos) & Right(Batch, Len(Batch) - pos) + 1
'Show the batch number label (cannot be edited)
Me.lblBatch.Visible = True
'Hide the batch number texbox (can be edited)
Me.txtBatch.Visible = False
End Sub
'**************************************************************************************
'* ObjectName : optNewCure *
'* Event : Click *
'* Description : When this option is clicked the batch number textbox is shown with a *
'* batch number begin. (A0_year_) *
'**************************************************************************************
Private Sub optNewCure_Click()
'Hide the batch number label (cannot be edited)
Me.lblBatch.Visible = False
'Show the batch number textbox (can be edited)
Me.txtBatch.Visible = True
If Batch <> "" Then
Me.txtBatch = "A0_" & Year(Now) & "_" & Format(Mid(Batch, 9, 4) + 1, "0000") & "_0"
End If
End Sub


'//////////////////////////////////////////////////////////////////////////////////////
'//
'//
'// FUNCTIONS
'//
'//
 

Similar Topics

Hello everyone, I was wondering if it would be possible to execute programs written in other languages on a panelview plus. Say I have visual c++...
Replies
1
Views
1,650
SInce i got no answers this week end I am posting this again.... For several days now I have been attempting to create a valid tag in RSView32 to...
Replies
4
Views
4,947
Hello, I have converted RSView 32 to FTView SE 14 (I have tested FTView 12 before as well and there were some difficulties so I moved on to...
Replies
4
Views
185
Okay, something I have not seen before.. RSView SE. I am working on an existing project. There is a value the customer wants trended and it is...
Replies
4
Views
742
I have a request to integrate a pause button in RSlogix to be able to start/stop a video. Video format is not defined at the moment, so it could...
Replies
2
Views
762
Back
Top Bottom