0% found this document useful (0 votes)
86 views29 pages

Program Maxum II

This document contains code for several subroutines in Visual Basic: 1. A subroutine that sets the active sequence for an application by updating a database table. 2. A subroutine that prepares results in a specific format for a host system by extracting data from database tables and setting values in an array based on result codes. 3. A subroutine that turns on a digital output (DO) by updating a database table. 4. A subroutine that sets a "RUN HOLD" DO to 0 if the application is in HOLD mode or 1 if it is in RUN mode by checking the application mode in a database table. 5. A subroutine that sets the values for up

Uploaded by

Acissey Antonio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views29 pages

Program Maxum II

This document contains code for several subroutines in Visual Basic: 1. A subroutine that sets the active sequence for an application by updating a database table. 2. A subroutine that prepares results in a specific format for a host system by extracting data from database tables and setting values in an array based on result codes. 3. A subroutine that turns on a digital output (DO) by updating a database table. 4. A subroutine that sets a "RUN HOLD" DO to 0 if the application is in HOLD mode or 1 if it is in RUN mode by checking the application mode in a database table. 5. A subroutine that sets the values for up

Uploaded by

Acissey Antonio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Sub main()

'==============================================================================
'Function: Sets any sequence as the active sequence
'Revision History: Author Date Comment
'3.2AA Dhiatt 5/18/01 Revised for 3.2
'Arguments: Appl
' iArg0 = ID of sequence
'
'==============================================================================
Dim sql As String
Dim n As Long
'
sql = "Update application Set active_app=" + Str$(Appl)
sql = sql + ", active_sequence = " + Str$(iArg0)
sql = sql + " Where application_id = " + Str$(Appl)
n = db.ExecuteSQL(sql)
End Sub
Sub main()
'*****************************************************************************
' this program prepares results in the HCI-A format for use with
' the results only type of host
' It places values in the results based on the trtval of the result
' trtval 1 = hourminute (4 digits)
' trtval 2 = day
' trtval 3 = month
' trtval 4 = year
' trtval 5 = stream
' trtval 6 = analyzer
' trtval 7 = status
' trtval 8 = alarm
' trtval 9 = peak 1
' trtval 10= peak 2
' ...
' Revision Author Date Comment
' 3.2AA DHiatt 6/15/01 Intitial version
'Input arguments: Appl, Strm
'***************************************************************************
Dim tblRes As Table
Dim tblSeq As Table
Dim tblSys As Table
Dim tblApp As Table
Dim tblStrm As Table
Dim n As Long
Dim sql As String
Dim fault As Integer
Dim warning As Integer
Dim i As Integer
Static result(8) As Double
Dim timestamp As String
Dim temptime
'open result table
' 0 1 2 3
sql = "Select application_id, stream_id, result_index, cycle_runtime"
sql = sql + " From result"
sql = sql + " Where application_id = " + Str$(Appl)
sql = sql + " And stream_id = " + Str$(Strm)
sql = sql + " And trtval =1 "
Set tblRes = db.OpenTable(sql)
'get date and time
timestamp = Mid$(tblRes(3),1,20)
temptime = CVDate(timestamp)
tblRes.Close
'extract hrmin from time
temptime = GmtToLocal(temptime)
Result(1) = CDbl(Format$(temptime,"hhmm"))
Result(2) = CDbl(Format$(temptime,"dd"))
Result(3) = CDbl(Format$(temptime,"mm"))
Result(4) = CDbl(Format$(temptime,"yy"))
Result(5) = CDbl(Strm)
sql = "Select id, lid From system_control"
Set tblSys = db.OpenTable(sql)
Result(6) = CDbl(tblSys(1))
tblSys.Close
' extract application state from application
' 0 1 2
sql = "Select application_id, mode, active_sequence From application "
sql = sql + " Where application_id = " + Str$(Appl)
Set tblApp = db.OpenTable(sql)
' 0 1 2
sql = "Select application_id, id, type From sequence "
sql = sql + " Where application_id =" + Str(Appl)
sql = sql + " And id = " + Str$(tblApp(2))
Set tblSeq = db.OpenTable(sql)
' set Result 7
If tblApp(1) = 0 Then
Result(7) = 0
Else
Result(7) = 1
End If
'
If tblSeq(2) = 2 And Result(7) = 1 Then
Result(7) = 2
End If
tblApp.Close
tblSeq.Close
'extract errors and warnings from stream table
' 0 1 2 3
sql = "Select application_id, stream_id, curr_error, curr_warning"
sql = sql + " From stream"
sql = sql + " Where application_id = " + Str$(Appl)
sql = sql + " And stream_id = " + Str$(Strm)
Set tblStrm = db.OpenTable(sql)
fault = tblStrm(2)
warning = tblStrm(3)
tblStrm.Close
' set result 8
If fault > 0 And fault < 256 Then
Result(8) = fault
ElseIf fault > 0 Then
Result(8) = 255
ElseIf warning > 0 And warning < 256 Then
Result(8) = warning
ElseIf warning > 0 Then
Result(8) = 127
Else
Result(8) = 0
End If
'update results
For i = 1 To 8
sql = "Update result Set buffered_Value = " + Str$(Result(i))
sql = sql + " Where application_id = " + Str$(Appl)
sql = sql + " And stream_id = " + Str$(Strm)
sql = sql + " And trtval = " + Str(i)
n = db.ExecuteSQL(sql)
Next i
End Sub
Sub main()
'Function: This program turns on a DO
'Revision History: Author date Comment
' 3.2AA DHiatt 6/4/01 rewritten for 3.2
'
'Arguments: Appl, Strm
' iArg0 - id of DO to set
Dim n As Long
Dim sql As String
' set DO on
sql = "Update appdo Set value = true"
sql = sql + " Where application_id = " + Str$(Appl)
sql = sql + " And id = " + Str$(iArg0)
n = db.ExecuteSQL(sql)
End Sub
Sub main()
'=======================================================================
' Function: If analyzer is in HOLD, then set RUN HOLD DO = 0
' If analyzer is in RUN, then set RUN HOLD DO = 1
'Revision History: Author Date Comment
'3.2AA DHiatt 6/5/01 Revised for 3.2
' Real Arguments: None
' Integer Arguments: Appl
' iArg0 = DO id to set
' Schedule: Frequency = 15 seconds
'===========================================================================
Dim N As Long
Dim SQL As String
Dim Tbl As Table
Dim AppMode As Long
'
' save the current status for the application: run or hold
' 0 1
SQL = "Select application_id, mode From application"
SQL = " Where application_id = " + Str$(Appl)
SQL = SQL + " Order By application_id"
Set Tbl = db.OpenTable(SQL)
AppMode = Tbl(1)
Tbl.Close
'
'If the application is running, mode = "1", set RUN HOLD DO = 1
'If the application is in HOLD, mode = "0", set RUN HOLD DO = 0
If AppMode = 0 Then
SQL = "Update appdo Set value = false"
Else
SQL = "Update appdo Set value = true"
End If

SQL = SQL + " Where application_id = " + Str$(Appl)


SQL = SQL + " And id = " + Str$(iArg0)
N = db.ExecuteSQL(SQL)
'
'
End Sub
Sub main()
'===================================================================
'Function:
'This program sets the value for up to 20 stream IDs in the appdo table
'This program is scheduled by mvrpgm.
'
'Revision History: Author Date Comments
' 3.2AA DHiatt 6/5/01 Revised for 3.2
'Arguments: Appl, Strm, Method
' iArg0 - stream 1 DO
' iArg1 - stream 2 DO
' iArg2 - stream 3 DO
' ....
' iArg19 - stream 20 DO
'===================================================================
'Variables
Dim n As Long
Dim sql As String
Dim i As Integer
Static DO_id(20)

'===================================================================
DO_id(0) = iArg0
DO_id(1) = iArg1
DO_id(2) = iArg2
DO_id(3) = iArg3
DO_id(4) = iArg4
DO_id(5) = iArg5
DO_id(6) = iArg6
DO_id(7) = iArg7
DO_id(8) = iArg8
DO_id(9) = iArg9
DO_id(10) = iArg10
DO_id(11) = iArg11
DO_id(12) = iArg12
DO_id(13) = iArg13
DO_id(14) = iArg14
DO_id(15) = iArg15
DO_id(16) = iArg16
DO_id(17) = iArg17
DO_id(18) = iArg18
DO_id(19) = iArg19
'

For i = 1 To 20
If Strm = i Then
sql = "Update appdo Set value = true"
Else
sql = "Update appdo Set value = false"
End If
sql = sql + " Where application_id = " + Str$(Appl)
sql = sql + " And id = " + Str$(DO_id(i - 1))
n = db.ExecuteSQL(sql)
Next i

'===================================================================
'Mvr, Trt, and Log will occur automatically if set in the stream_method table
'release end of cycle processing
sql = "Send 'release_eoc' To stream_method Where application_id = " + Str$(Appl)
sql = sql + " And stream_id = " + Str$(Strm)
sql = sql + " And method_id = " + Str$(Method)
n = db.ExecuteSQL(sql)
'MsgBox "End"
End Sub

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy