Wednesday, February 1, 2023

Installasi Application SAP HANA & Client Pada Linux SUSE

 


Berikut adalah cara aplikasi SAP HANA dan Client

1. Aplikasi SAP HANA

1.1. Buka terminal. kemudian ketik : cd/mnt/winSource/FolderSAPHANA/HANADB/DATA_UNITS/SAP\ HANA\AFL\ 1.0\ FOR\ B1/LINX64SUSE/SAP_HANA_AFL 


Catatan : Jangan copy paste command, tapi diketik , bisa menggunakan tombol tab pada keyboard 

1.2. Ketik perintah : ./hdbinst

1.3. Apabila sudah selesai maka akan tampil gambar seperti dibawah.



2. SAP HANA Client 

SAP HANACLIENT mempunyai 2 versi yaitu 32 bit & 64 bit

2.1. Buka terminal. kemudian ketik cd/mnt/winSource/FolderSAPHANA/HANADB/DATA_UNITS/SAP HANA CLIENT 1.0 FOR B1/LINX32SUSE/SAP_HANA_CLIENT, lalu Enter. 

Selanjutnya Ketik command line ./hdbinst

2. Setelah menjalankan perintah ./hdbinst maka akan langsung menjalankan proses installasi.


2.3. Apabila installasi versi 32bit sudah selesai, lanjutkan yang 64bit.

Ketikan :

cd/mnt/winSource/FolderSAPHANA/HANADB/DATA_UNITS/SAP HANA CLIENT 1.0 FOR B1/LINX64SUSE/SAP_HANA_CLIENT 

Kemudian ketik : ./hdbinst

2.3. Tunggu sampai proses installasi selesai.


Catatan : 

Menggunakan perintah ./hdbinst, apabila tidak mau menampilkan GUI,  ./hdbsetup apabila ingin menggunakan GUI.

Installasi Database HANA Pada Linux SUSE

 



Persiapkan yang diperlukan adalah : 
  • PC/Server Linux :  ini disebabkan database HANA for SAP B1 hanya berjalan di OS Suse Linux 
  • Download Installer HANA SAP B1,  login menggunakan SID Partner SAP.
  • Siapkan file Installer HANA,  pada tutor ini sudah ada di linux server maka copy kan ke Windows Server.  ( Baca : Sharing Folder OS Windows Dengan Linux )


Install Database HANA 

1.  Mounting folder, buka terminal lalu ketikan :  
  mount -o username=administratorWindows,password=passwordWindows //IPAddressWindowsServer/ShareFolder /mnt/winSource


Setelah itu, ketikan cd /mnt/winSource/NamaFolderInstallerHANA  lalu enter. Kemudian cari folder cd /HANADB/DATA_UNIT/


2. Jika Muncul Tampilan seperti gambar dibawah, klik Next


3. Isi pada SAP HANA System ID : DB1 dan Instance Number ( Default 00 ). Klik Next.


4. Masukan password, setelah itu klik Next.


5. Klik Next.


6. Masukan password untuk login ke Database HANA sedangkan Username akan secara otomatis terisi SYSTEM. Kemudian klik Next


7. Klik Next.


8. Tunggu sampai proses intall selesai



10. Klik Finish. 



Contoh Mengakses PLC Dengan Visual Basic.Net - IV

 

13. Start and stop a PLC

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

#Region "StartPLC"

    Private Sub btnStartPLC_Click(sender As Object, e As EventArgs) Handles btnStartPLC.Click

        'execute function

        Dim res As OperationResult = Device.StartPLC()

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality.Equals(OperationResult.eQuality.GOOD) Then

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

#End Region

 

#Region "StopPLC"

    Private Sub btnStopPLC_Click(sender As Object, e As EventArgs) Handles btnStopPLC.Click

        'execute function

        Dim res As OperationResult = Device.StopPLC()

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality.Equals(OperationResult.eQuality.GOOD) Then

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

#End Region

End Class


14. Reading block list from PLC

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnGetBlockList_Click(sender As Object, e As EventArgs) Handles btnGetBlockList.Click

        Dim BlockType As eBlockType = eBlockType.AllBlocks

        Dim res As BlockListResult = Device.GetBlockList(BlockType)

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        txtResult.Text = String.Empty

        If res.Quality = OperationResult.eQuality.GOOD Then

            Dim sb As New System.Text.StringBuilder()

            For Each ble As BlockListEntry In res.BlockList

                sb.Append(ble.BlockType.ToString())

                sb.Append(ble.BlockNumber.ToString())

                sb.Append(Environment.NewLine)

            Next

            txtResult.Text = sb.ToString()

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

End Class


15. Get length of block

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnGetBlockLen_Click(sender As Object, e As EventArgs) Handles btnGetBlockLen.Click

        'get Len from DB100

        Dim BlockNumber As Integer = 100

        Dim BlockType As eBlockType = eBlockType.DB

 

        'evaluate results

        Dim res As BlockListLengthResult = Device.GetBlockLenght(BlockType, BlockNumber)

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        txtMessage.ForeColor = If(res.Quality = OperationResult.eQuality.GOOD, Color.Black, Color.Red)

        txtResult.Text = String.Empty

        If res.Quality = OperationResult.eQuality.GOOD Then

            Dim sb As New System.Text.StringBuilder()

            sb.Append(res.BlockType.ToString())

            sb.Append(res.BlockNumber.ToString())

            sb.Append(" Len:")

            sb.Append(res.BlockLength.ToString())

            sb.Append(Environment.NewLine)

            txtResult.Text = sb.ToString()

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

End Class


16. Backup block

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnBackupBlock_Click(sender As Object, e As EventArgs) Handles btnBackupBlock.Click

        'Backup OB1

        Dim BlockNumber As Integer = 1

        Dim Blocktype As eBlockType = eBlockType.OB

        'open SaveFileDialog

        Dim sfd As New SaveFileDialog()

        sfd.Filter = "*.mc7|*.mc7|*.bin|*.bin|*.*|*'.*"

        Dim dr As DialogResult = sfd.ShowDialog()

        If dr = DialogResult.OK Then

            'read Block into ReadPLCBlockResult

            Dim res As ReadPLCBlockResult = Device.ReadPLCBlock_MC7(Blocktype, BlockNumber)

            txtMessage.Text = res.Message

            txtResult.Text = ""

            If res.Quality = OperationResult.eQuality.GOOD Then

                'save buffer in specified file

                Dim fs As New System.IO.FileStream(sfd.FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)

                fs.Write(res.Buffer, 0, res.Buffer.Length)

                fs.Close()

                MessageBox.Show(("Block " & Blocktype.ToString() & BlockNumber.ToString() & " successful saved in ") + sfd.FileName, "", MessageBoxButtons.OK, MessageBoxIcon.Information)

            Else

                MessageBox.Show("operation unsuccessful", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

            End If

        Else

            MessageBox.Show("operation aborted", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

        End If

    End Sub

End Class


17. Restore block

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnRestoreBlock_Click(sender As Object, e As EventArgs) Handles btnRestoreBlock.Click

        Dim ofd As New OpenFileDialog()

        ofd.Filter = "*.mc7|*.mc7|*.bin|*.bin|*.*|*'.*"

        Dim dr As DialogResult = ofd.ShowDialog()

        If dr = DialogResult.OK Then

            Dim fs As New System.IO.FileStream(ofd.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)

            Dim buffer As Byte() = New Byte(fs.Length - 1) {}

            fs.Read(buffer, 0, CInt(fs.Length))

            fs.Close()

            'Write Buffer into PLC

            Dim Requestdata As New WritePLCBlockRequest(buffer, eBlockType.OB, 1)

            Dim res As OperationResult = Device.WritePLCBlock_MC7(Requestdata)

            txtMessage.Text = res.Message

            txtResult.Text = ""

            If res.Quality = OperationResult.eQuality.GOOD Then

                MessageBox.Show(("Block " & Requestdata.BlockInfo.Header.BlockType.ToString() & Requestdata.BlockInfo.Header.BlockNumber.ToString() & " successful saved in PLC from Source ") + ofd.FileName, "", MessageBoxButtons.OK, MessageBoxIcon.Information)

            Else

                MessageBox.Show("operation unsuccessful", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

            End If

        Else

            MessageBox.Show("operation aborted", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

        End If

    End Sub

End Class


18. Delete block

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnDeleteBlock_Click(sender As Object, e As EventArgs) Handles btnDeleteBlock.Click

        'Delete DB100

        Dim BlockNumber As Integer = 100

        Dim BlockType As eBlockType = eBlockType.DB

 

        Dim res As OperationResult = Device.DeleteBlock(BlockType, BlockNumber)

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality = OperationResult.eQuality.GOOD Then

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

End Class


Reference : https://www.plccom.net/en/plccom/for-s7/fors7-code-examples/

Contoh Mengakses PLC Dengan Visual Basic.Net - III

 

9. Get or set PLC time

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

#Region "getPLCClockTime"

    Private Sub btnGetPLCClockTime_Click(sender As Object, e As EventArgs) Handles btnGetPLCClockTime.Click

        'execute function

        Dim res As PLCClockTimeResult = Device.GetPLCClockTime()

 

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality.Equals(OperationResult.eQuality.GOOD) Then

            txtResult.Text = res.PLCClockTime.ToString()

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

#End Region

 

#Region "setPLCClockTime"

    Private Sub btnSetPLCClockTime_Click(sender As Object, e As EventArgs) Handles btnSetPLCClockTime.Click

        'execute function

        Dim res As OperationResult = Device.SetPLCClockTime(DateTime.Now)

 

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality.Equals(OperationResult.eQuality.GOOD) Then

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

#End Region

End Class


10. Reading system status list SSL

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnGetSSL_Click(sender As Object, e As EventArgs) Handles btnGetSSL.Click

        ' important!!! please search the id and index information in the plc-documentation

        ' You must convert the specified values hex in decimal

        Dim SSL_ID As Integer = 306

        'ID 132 (Hex) 

        Dim SSL_Index As Integer = 4

        'Index 4 (Hex) 

        'execute function

        Dim res As SystemStatusListResult = Device.GetSystemStatusList(SSL_ID, SSL_Index)

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality = OperationResult.eQuality.GOOD Then

            Dim sb As New System.Text.StringBuilder()

            For Each ssle As SystemStatusListResult.SystemStatusListItemEntry In res.SZLItemEntrys

                For Each b As Byte In ssle.buffer

                    sb.Append(b.ToString())

                    sb.Append(" ")

                Next

                sb.Append(Environment.NewLine)

            Next

            txtResult.Text = sb.ToString()

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

End Class


11. Get diagnostic data

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnDiagnosticInfo_Click(sender As Object, e As EventArgs) Handles btnDiagnosticInfo.Click

        'read the diagnosticinfo into DiagnosticInfoResult-object

        'execute function

        Dim res As DiagnosticInfoResult = Device.GetDiagnosticInfo()

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality = OperationResult.eQuality.GOOD Then

            Dim sb As New System.Text.StringBuilder()

            'step through the entries

            For Each myDiagnosticInfoEntry As DiagnosticInfoEntry In res.DiagnosticInfoEntrys

                sb.Append("Timestamp: " & myDiagnosticInfoEntry.DiagnosticTimestamp.ToString())

                sb.Append(" ")

                sb.Append("ID: " & myDiagnosticInfoEntry.DiagnosticID.ToString())

                sb.Append(" ")

                sb.Append("Message: " + myDiagnosticInfoEntry.DiagnosticText)

                sb.Append(Environment.NewLine)

            Next

            txtResult.Text = sb.ToString()

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

End Class


12. Send password

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnSendPW_Click(sender As Object, e As EventArgs) Handles btnSendPW.Click

        Dim res As OperationResult = Device.sendPassWord("EnterPW")

 

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality = OperationResult.eQuality.GOOD Then

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

End Class


Reference : https://www.plccom.net/en/plccom/for-s7/fors7-code-examples/

Contoh Mengakses PLC Dengan Visual Basic.Net - II

 

5. Simple writing data to PLC

Imports PLCcom

Imports System.Windows.Forms

 

Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

 

    Private Sub btnWrite_Click(sender As Object, e As EventArgs)

        'declare a WriteDataRequest object and

        'write 4 bytes in DB100 at Startbyte 0

        Dim myWriteRequest As New WriteDataRequest(eRegion.DataBlock, 100, 0)

        'add writable Data here

        myWriteRequest.addByte(New Byte() {11, 12, 13, 14})

        'write

        Dim res As WriteDataResult = Device.WriteData(myWriteRequest)

 

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality.Equals(OperationResult.eQuality.GOOD) Then

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

End Class


6. Optimized reading and writing of data

Imports PLCcom

 

Namespace CodeDokuCSharp

    Class newClass

        Private Device As PLCcomDevice 'see section 'connect' for declare and connect a PLCcom-Device

 

        Private Sub btnoptReadWrite_Click(sender As Object, e As EventArgs)

 

            Dim myRequestSet As ReadWriteRequestSet = New ReadWriteRequestSet()

             

            //set optimize options

            myRequestSet.SetOperationOrder(eOperationOrder.WRITE_BEVOR_READ)

            myRequestSet.SetReadOptimizationMode(eReadOptimizationMode.AUTO)

            myRequestSet.SetWriteOptimizationMode(eWriteOptimizationMode.CROSS_AREAS)

             

             

            'declare a ReadRequest object set the request parameters, 'in this case => read 10 Bytes from DB1 at Byte 0

            Dim myReadDataRequest As ReadDataRequest = New ReadDataRequest(eRegion.DataBlock, _

            1, _

            0, _

            eDataType.[BYTE], _

            10)

             

            'add the read request to the request set

            myRequestSet.AddRequest(myReadDataRequest)

            Dim myWriteRequest As WriteDataRequest = New WriteDataRequest(eRegion.DataBlock, 100, 0)

                           

            'add writable Data here

            'in  this case => write 4 bytes in DB100

            myWriteRequest.addByte(New Byte() { 11, 12, 13, 14 })

             

            'add the write request to the request set

            myRequestSet.AddRequest(myWriteRequest)

             

            '....... add more requests to request set

             

            'read, write and getting the results

            Dim results As ReadWriteResultSet = Device.ReadWriteData(myRequestSet)

             

            'evaluate results

            'evaluate the results of read operations...

            For Each res As ReadDataResult In results.GetReadDataResults()

                

            Next

             

            '...and evaluate the results of write operations

            For Each res As WriteDataResult In results.GetWriteDataResults()

                

            Next

 

        End Sub

    End Class

End Namespace


7. Get basic info from PLC

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub getGetPLCBasicInfo_Click(sender As Object, e As EventArgs) Handles getGetPLCBasicInfo.Click

        'execute function

        Dim res As BasicInfoResult = Device.GetBasicInfo()

 

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality = OperationResult.eQuality.GOOD Then

            Dim sb As New System.Text.StringBuilder()

            sb.Append("Device Name: ")

            sb.Append(res.Name)

            sb.Append(Environment.NewLine)

            sb.Append("Order Number: ")

            sb.Append(res.OrderNumber)

            sb.Append(Environment.NewLine)

            sb.Append("Module Version: ")

            sb.Append(res.ModuleVersion)

            sb.Append(Environment.NewLine)

            sb.Append("Firmware Version: ")

            sb.Append(res.FirmwareVersion)

            sb.Append(Environment.NewLine)

            txtResult.Text = sb.ToString()

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

 

End Class


8. Get mode and state from CPU

Imports PLCcom

Public Class newClass

    Private Device As PLCcomDevice

    'see section 'connect' for declare and connect a PLCcom-Device

    Private Sub btnGetCPUMode_Click(sender As Object, e As EventArgs) Handles btnGetCPUMode.Click

        'execute function

        Dim res As CPUModeInfoResult = Device.GetCPUMode()

 

        'evaluate results

        txtMessage.Text = (DateTime.Now.ToString() & ": ") + res.Message

        If res.Quality = OperationResult.eQuality.GOOD Then

            txtResult.Text = ("CPU Mode = " & res.CPUModeInfo.ToString()) + Environment.NewLine & "CPU State = " & res.CPUStateInfo.ToString()

            MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else

            MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

    End Sub

End Class


Reference : https://www.plccom.net/en/plccom/for-s7/fors7-code-examples/

Contoh Mengakses PLC Dengan Visual Basic.Net - I

 

Programmable Logic Controller, disingkat PLC merupakan peralatan elektronik yang dibangun dari mikroprosesor untuk memonitor keadaan dari peralatan input untuk kemudian di analisa sesuai dengan kebutuhan perencana (programmer) untuk mengontrol keadaan output. Sinyal input diberikan kedalam input card.

Ada 2 jenis input card, yaitu :

Analog input card

Digital input card


Contoh untuk mengakses PLC :

1. Connect to PLC

Imports PLCcom

 

Public Class myTestClass

    Private Device As PLCcomDevice 

    Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click

 

            'create TCP_ISO_Device instance from PLCcomDevice

            Device = New TCP_ISO_Device("192.168.1.2", 0, 2, ePLCType.S7_300_400_compatibel)

            'or create MPI_Device instance from PLCcomDevice 

            'Device = New MPI_Device("COM2", 0, 2, eBaudrate.b38400, eSpeed.Speed187k, ePLCType.S7_300_400_compatibel) 

            'or create PPI_Device instance from PLCcomDevice 

            'Device = New PPI_Device("COM2", 0, 2, eBaudrate.b9600, ePLCType.S7_200_compatibel)

 

        authentication.User = "" 'Enter User here

        authentication.Serial = "" 'Enter Serial here

         

        Device.Connecttimeout = 1000

        Device.Readtimeout = 2000 

        Dim res As ConnectResult = Device.Connect()

         

        MessageBox.Show(res.Message)

 

    End Sub

End Class


2. Disconnect from PLC

Untuk memutuskan koneksi ke PCL hanya 1 baris perintah : Device.DisConnect()


3. Automatic connect to PLC

Imports PLCcom

 

Public Class myTestClass

    'declare the Device 

    Private Device As PLCcomDevice

    Private Sub btnConnect_Click(sender As Object, e As System.EventArgs)

        'create TCP_ISO_Device instance from PLCcomDevice

        Device = New TCP_ISO_Device("192.168.1.2", 0, 2, ePLCType.S7_300_400_compatibel)

        'or create MPI_Device instance from PLCcomDevice 

        'Device = new MPI_Device("COM2", 0, 2, eBaudrate.b38400, eSpeed.Speed187k, ePLCType.S7_300_400_compatibel); 

        'or create PPI_Device instance from PLCcomDevice 

        'Device = new PPI_Device("COM2", 0, 2, eBaudrate.b9600, ePLCType.S7_200_compatibel);

 

        authentication.User = ""

        authentication.Serial = ""

 

        'Set auto connect

        'The connection is opened automatically when it is needed. If after the expiry of the given period, no more requests are sent, the connection is automatically closed.

        Device.setAutoConnect(True, 10000)

    End Sub

End Class


4 . Simple reading data from PLC

Imports PLCcom

Imports System.Windows.Forms

 

Namespace CodeDokuCSharp

    Class newClass

        Private Device As PLCcomDevice

 

        Private Sub btnRead_Click(sender As Object, e As EventArgs)

            'declare a ReadRequest object

            'set the request parameters

            'read 10 Bytes from DB100

            Dim myReadRequest As New ReadDataRequest(eRegion.DataBlock, 100, 0, eDataType.[BYTE], 10)

 

            'read from device

            Dim res As ReadDataResult = Device.ReadData(myReadRequest)

 

            'evaluate results

            txtMessage.Text = res.Message

            If res.Quality = OperationResult.eQuality.GOOD Then

                For Each b As Byte In DirectCast(res.GetValues(), Byte())

                    txtResult.Text += b.ToString() & Environment.NewLine

                Next

                MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

            Else

                MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information)

            End If

        End Sub

    End Class

End Namespace



Reference : https://www.plccom.net/en/plccom/for-s7/fors7-code-examples/


Contoh Mengakses PLC Dengan C# - IV

 


13. Start and stop a PLC

using System;

using PLCcom;

using System.Windows.Forms;

 

namespace CodeDokuCSharp

{

    class newClass

    {

        PLCcomDevice Device;

        //see section 'connect' for declare and connect a PLCcom-Device

 

        #region StartPLC

 

        private void btnStartPLC_Click(object sender, EventArgs e)

        {

            //execute function

            OperationResult res = Device.StartPLC();

 

            //evaluate results

            txtMessage.Text = DateTime.Now.ToString() + ": " + res.Message;

            if (res.Quality.Equals(OperationResult.eQuality.GOOD))

            {

                MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            else

            {

                MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

 

        #endregion

 

 

        #region StopPLC

 

        private void btnStopPLC_Click(object sender, EventArgs e)

        {

            //execute function

            OperationResult res = Device.StopPLC();

 

            //evaluate results

            txtMessage.Text = DateTime.Now.ToString() + ": " + res.Message;

            if (res.Quality.Equals(OperationResult.eQuality.GOOD))

            {

                MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            else

            {

                MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

 

        #endregion

 

    }

}


14. Reading block list from PLC

using System;

using PLCcom;

using System.Windows.Forms;

 

namespace CodeDokuCSharp

{

    class newClass

    {

        PLCcomDevice Device;

        //see section 'connect' for declare and connect a PLCcom-Device

 

        private void btnGetBlockInfo_Click(object sender, EventArgs e)

        {

 

            eBlockType BlockType = eBlockType.AllBlocks;

 

            BlockListResult res = Device.GetBlockList(BlockType);

 

            //evaluate results

            txtMessage.Text = DateTime.Now.ToString() + ": " + res.Message;

            txtResult.Text = string.Empty;

            if (res.Quality == OperationResult.eQuality.GOOD)

            {

                StringBuilder sb = new StringBuilder();

                foreach (BlockListEntry ble in res.BlockList)

                {

                    sb.Append(ble.BlockType.ToString());

                    sb.Append(ble.BlockNumber.ToString());

                    sb.Append(Environment.NewLine);

                }

                txtResult.Text = sb.ToString();

                MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            else

            {

                MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

    }

}


15. Get length of block

using System;

using PLCcom;

using System.Windows.Forms;

 

namespace CodeDokuCSharp

{

    class newClass

    {

        PLCcomDevice Device;

        //see section 'connect' for declare and connect a PLCcom-Device

 

        private void btnGetBlockLen_Click(object sender, EventArgs e)

        {

            //get Len from DB100

            int BlockNumber = 100;

            eBlockType BlockType = eBlockType.DB;

 

            //evaluate results

            BlockListLengthResult res = Device.GetBlockLenght(BlockType, BlockNumber);

 

            //evaluate results

            txtMessage.Text = DateTime.Now.ToString() + ": " + res.Message;

            txtMessage.ForeColor = res.Quality == OperationResult.eQuality.GOOD ? Color.Black : Color.Red;

            txtResult.Text = string.Empty;

            if (res.Quality == OperationResult.eQuality.GOOD)

            {

                StringBuilder sb = new StringBuilder();

                sb.Append(res.BlockType.ToString());

                sb.Append(res.BlockNumber.ToString());

                sb.Append(" Len:");

                sb.Append(res.BlockLength.ToString());

                sb.Append(Environment.NewLine);

 

                txtResult.Text = sb.ToString();

                MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            else

            {

                MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

    }

}


16. Backup block

using System;

using PLCcom;

using System.Windows.Forms;

namespace CodeDokuCSharp

{

    class newClass

    {

        PLCcomDevice Device;

        //see section 'connect' for declare and connect a PLCcom-Device

 

        private void btnBackupBlock_Click(object sender, EventArgs e)

        {

 

            //Backup OB1

            int BlockNumber = 1;

            eBlockType Blocktype = eBlockType.OB;

 

            //open SaveFileDialog

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "*.mc7|*.mc7|*.bin|*.bin|*.*|*'.*";

            DialogResult dr = sfd.ShowDialog();

            if (dr == DialogResult.OK)

            {

                //read Block into ReadPLCBlockResult

                ReadPLCBlockResult res = Device.ReadPLCBlock_MC7(Blocktype, BlockNumber);

                txtMessage.Text = res.Message;

                txtResult.Text = "";

                if (res.Quality == OperationResult.eQuality.GOOD)

                {

                    //save buffer in specified file

                    System.IO.FileStream fs = new System.IO.FileStream(sfd.FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write);

                    fs.Write(res.Buffer, 0, res.Buffer.Length);

                    fs.Close();

                    MessageBox.Show("Block " + Blocktype.ToString() + BlockNumber.ToString() + " successful saved in " + sfd.FileName, "", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }

                else

                {

                    MessageBox.Show("operation unsuccessful", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                }

            }

            else

            {

                MessageBox.Show("operation aborted", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }

        }

 

    }

}


17. Restore block

using System;

using PLCcom;

using System.Windows.Forms;

 

namespace CodeDokuCSharp

{

    class newClass

    {

        PLCcomDevice Device;

        //see section 'connect' for declare and connect a PLCcom-Device

 

        private void btnRestoreBlock_Click(object sender, EventArgs e)

        {

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "*.mc7|*.mc7|*.bin|*.bin|*.*|*'.*";

            DialogResult dr = ofd.ShowDialog();

            if (dr == DialogResult.OK)

            {

 

                System.IO.FileStream fs = new System.IO.FileStream(ofd.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);

                byte[] buffer = new byte[fs.Length];

                fs.Read(buffer, 0, (int)fs.Length);

                fs.Close();

 

                //Write Buffer into PLC

                WritePLCBlockRequest Requestdata = new WritePLCBlockRequest(buffer, eBlockType.OB, 1);

                OperationResult res = Device.WritePLCBlock_MC7(Requestdata);

                txtMessage.Text = res.Message;

                txtResult.Text = "";

                if (res.Quality == OperationResult.eQuality.GOOD)

                {

 

                    MessageBox.Show("Block " + Requestdata.BlockInfo.Header.BlockType.ToString() + Requestdata.BlockInfo.Header.BlockNumber.ToString() + " successful saved in PLC from Source " + ofd.FileName, "", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }

                else

                {

                    MessageBox.Show("operation unsuccessful", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                }

            }

            else

            {

                MessageBox.Show("operation aborted", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }

        }

    }

}


18. Delete block

using System;

using PLCcom;

using System.Windows.Forms;

 

namespace CodeDokuCSharp

{

    class newClass

    {

        PLCcomDevice Device;

        //see section 'connect' for declare and connect a PLCcom-Device

 

        private void btnDeleteBlock_Click(object sender, EventArgs e)

        {

            //Delete DB100

            int BlockNumber = 100;

            eBlockType BlockType = eBlockType.DB;

 

            OperationResult res = Device.DeleteBlock(BlockType, BlockNumber);

            //evaluate results

            txtMessage.Text = DateTime.Now.ToString() + ": " + res.Message;

            if (res.Quality == OperationResult.eQuality.GOOD)

            {

                MessageBox.Show("OK", "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            else

            {

                MessageBox.Show(res.Message, "Result:", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

    }

}


Reference : https://www.plccom.net/en/plccom/for-s7/fors7-code-examples/

Memunculkan Simbol & Emoji Pada OS Mac

  Memunculkan Simbol & Emoji  1. Buka aplikasi Pages / Notes pada Macbook. 2. Klik pada Menubar Edit --> Pilih Emoji and Symbols a...