opc with visual studio video

Download OPC with Visual Studio Video

Post on 03-Jan-2017

214 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

  • OPCwithVisualStudio

    Hans-PetterHalvorsen,M.Sc.

  • Software MatrikonOPCSimulationServer VisualStudio MeasurementStudioAdd-onpackagetoVisualStudiocreatedbyNationalInstruments(samevendorasLabVIEW)

  • MeasurmentStudio Add-onpackagetoVisualStudiocreatedbyNationalInstruments

    SamevendorasLabVIEW MakesitpossibletocommunicatewithanOPCDAServerfromVisualStudioCode

    UsestheDataSocket Library(sameasinLabVIEW)

  • OPC

    Hans-PetterHalvorsen,M.Sc.

  • WhatisOPC? Astandardthatdefinesthecommunicationofdatabetweendevicesfromdifferentmanufactures

    RequiresanOPCserverthatcommunicateswiththeOPCclients

    OPCallowsplug-and-play,givesbenefitsasreducesinstallationtimeandtheopportunitytochooseproductsfromdifferentmanufactures

    Differentstandards:Real-timedata(OPCDA),Historicaldata(OPCHDA),Alarm&Eventdata(OPCAE),etc.

  • OPC

    OPCServer OPCClientRead/WriteData

    DataStorage

  • OPCServer

    OPCClient

    WriteData

    DataStorage

    OPCClient

    ReadData

    MeasurementData

    Monitoring andAnalysis

  • OPC-Server

    Network

    OPC-Client OPC-ClientOPC-Client

    Process

    ProcessData

    DataAcquisitionPLC,PAC,DCS,SCADA

    TypicalOPCScenario

    Driver

    SensorsActuators

  • OPCSpecifications

    OPCDA

    OPCHDA

    OPCA&E

    OPCUA

    ClassicOPC NextGenerationOPC

    ...(Manyothers)

  • OPCSpecifications OPCDA(DataAccess)ThemostcommonOPCspecificationisOPCDA,whichisusedtoreadandwritereal-timedata.WhenvendorsrefertoOPCgenerically,theytypicallymeanOPCDA. OPCHDA(HistoricalDataAccess) OPCA&E(Alarms&Events) ...(manyothers)TheseOPCspecificationarebasedontheOLE,COM,andDCOMtechnologiesdevelopedbyMicrosoftfortheMicrosoftWindowsoperatingsystemfamily.ThismakesitcomplicatedtomakeitworkinamodernNetwork!TypicallyyouneedaTunneller SoftwareinordertosharetheOPCdatainanetwork(betweenOPCServersandClients)

    OPCUA(UnifiedArchitecture)OPCUAeliminatingtheneedtouseaMicrosoftWindowsbasedplatformofearlierOPCversions.OPCUAcombinesthefunctionalityoftheexistingOPCinterfaceswithnewtechnologiessuchasXMLandWebServices(HTTP,SOAP)

  • NextGenerationOPC

    OPCClassic OPCUA

    OPCDAServer

    OPCHDAServer

    OPCA&EServer

    COM/DCOM XML,HTTP,SOAP

    Cross-platformWindowsonly Allspecificationscollectedinone(DA,HDA,A&E)

    NextGenerationOPC

    OPCClient(DCOM)

    OPCDAOPCHDA

    OPCA&E

    OPCUAServer OPCUAClient

    Protocols:UABinaryorUAXML

    Windows,Linux,Mac,Embedded,VxWorks

    Simpler!!

    (everything builtintoone)

  • NextGenerationOPC

    OPCClassicServer OPCClassicClient

    OPCUAServer OPCUAClientNetwork/Internet

    ToopenDCOMthrough firewallsdemandedalargehole inthefirewall!Impossible torouteoverInternet!

    Nohole infirewall(UAXML)orjustasimpleneedlestick(UABinary)isnecessaryEasytorouteoverInternet!

    Network

  • ClassicOPCvs.OPCUAClassicOPC(DCOM) OPCUA

    OPCServer

    OPCClient

    OPCClient

    OPCClient

    Windows

    Windows

    Windows

    WindowsOPCUAServer

    OPCUAClient

    OPCUAClient

    ClassicOPCrequiresaMicrosoftWindowsoperatingsystemtoimplementCOM/DCOMserverfunctionality.ByutilizingSOAandWebServices,OPCUAisaplatform-independentsystemthateliminatesthepreviousdependencyonaWindowsoperatingsystem.ByutilizingSOAP/XMLoverHTTP,OPCUAcandeployonavarietyofembeddedsystemsregardlessofwhetherthesystemisageneralpurposeoperatingsystem, suchasWindows,oradeterministicreal-timeoperatingsystem. http://www.ni.com/white-paper/13843/en/

    OPCUAClient

    Theserver(orclients)canbeanembeddedsystem,LINUX,Windows, etc.

  • MatrikonOPCSimulationServer

    Hans-PetterHalvorsen,M.Sc.

  • Matrikon OPCExplorer ConnecttoServer

    1

    2

  • Matrikon OPCExplorer- AddTags

    1

    2

    3

    4

    5

    Double-click

    Finished

  • MatrikonOPCExplorer(OPCClient)

    TheMatrikonOPCExplorerisusefulfortesting.YoucanuseitforwritingandreadingOPCTags

  • MeasurementStudio

    Hans-PetterHalvorsen,M.Sc.

  • MeasurmentStudio Add-onpackagetoVisualStudiocreatedbyNationalInstruments

    SamevendorasLabVIEW MakesitpossibletocommunicatewithanOPCDAServerfromVisualStudioCode

    UsestheDataSocketLibrary(sameasinLabVIEW)

  • MeasurementStudio MeasurementStudioisanadd-ontoVisualStudio. MeasurementStudioisusedfordevelopmentofmeasurement,controlandmonitoringapplicationsusing.NETandVisualStudio.

    MeasurementStudiohasalibrary(DataSocket library)thatmakesitpossibletocommunicatewithOPCDAserversthatwewilluseisthislabwork

    DownloadSoftwarehere:http://www.ni.com/academic/download

    20

    Software

  • VisualStudioEditionsq IhaveVisualStudio2013 YoucanInstallanduseMeasurementsStudio2015withoutproblems

    q IhaveVisualStudio2015 MeasurementStudio2015isdesignedtoworkwithVisualStudio2013(andoldereditions).

    Therefore,MeasurementStudio2015doesnotinstallshippingexamplesanddoesnotintegratewithVisualStudio2015

    Thismeans,ifyouinstallMeasurementStudio2015withVisualStudio2015,theMeasurementStudio.NETcontrolsarenotintheToolbox,andyoudonothaveaMeasurementStudiomenuitemintheVisualStudio2015toolbar.

    Followtheseguidelinestodothismanually:http://home.hit.no/~hansha/documents/control/opc/resources/Using%20Measurement%20Studio%202015.pdf

  • MeasurementStudio2015MeasurementStudio2015doesnothaveintegrationfeaturesforVisualStudio2015.IfyouinstallMeasurementStudio2015withVisualStudio2015,theMeasurementStudio.NETcontrolsarenotintheToolbox,youdonothaveaMeasurementStudiomenuitemintheVisualStudio2015 toolbar,and.licxwillnotbeautomaticallygenerated.WehaveplanstomakechangestoMeasurementStudiothatwillhelpusbetterkeepupwithnewversions.Unfortunately,thesechangesareaquiteabitmorecostlythanit wouldseem,particularlytheVisualStudioHelpintegration,sothesechangesmaynotcomesoon.

    ThissituationisthesameaspreviousMeasurementStudiosoftwareasinthefollowingarticle'UsingMeasurementStudio2013withMicrosoftVisualStudio2013':http://digital.ni.com/public.nsf/allkb/C51E3B38578FAD2786257C070069F386

    VisualStudio2015isnot supportedofficiallyinMeasurementStudio2015;however,asintheabovearticle,youcanaddtheMeasurementStudio.NETcontrolstotheToolboxmanuallyandcancreate.licx filesmanually.IhaveattachedaHelpDocumentonthistopicsoyoucanrefertothe AddingMeasurementStudio2015UserInterfaceControls totheToolbox sectionformoreinformationonHowtoAddcontrols.Thissectionalsodescribeshowthesecontrolsarelicensed.ThefollowingsectionsdiscussadditionaltopicstoconsiderwhenusingMeasurementStudio2015withVisualStudio2015.

    RebeccaCostinNationalInstrumentsApplicationsEngineeringwww.ni.com/support

  • VisualStudio2013+MeasurementStudioSelectNewProjectinVisualStudio:

    MakesuretoselecttheDataSocketLibrary

    SelecttheNIWindowsApplicationTemplate

    12

    3

    4

    5

    76

    8

    MeasurementStudio isanAdd-inforVisualStudiocreatedbyNationalInstruments.

    Note!YoudontneedtousetheMeasurmentStudioTemplates YoucanuseanordinaryWinFormAppalso!!

  • VisualStudio2015+MeasurementStudioYoucanuseanordinaryWinFormApp

    Thenyouneedto:1. AddReferences(Assemblies)

    Manually2. Change/UpdatetheLicenseFile

    (Licenses.licx)

  • AddingReferencestoyourProjectYouneedtoaddtheseAssemblies(.dllfiles)toyourVisualStudioProject

    LocatethefollowingAssembliesonyourharddrive:NationalInstruments.Common.dllNationalInstruments.Net.dll

    C:\ProgramFiles\NationalInstruments\MeasurementStudioVSXXXX\DotNET\Assemblies\Current\...

  • LicenseFile

    NationalInstruments.Net.DataSocket,NationalInstruments.Net,Version=13.0.45.242,Culture=neutral,PublicKeyToken=4febd62461bf11a4

    Youmayneed toupdatetheLicenseFilewithcorrectVersionNumberandPublicKeyToken accordingtotheinstalledAssembliesyouhaveonyourharddrive

  • OPCReadExample

    Hans-PetterHalvorsen,M.Sc.

  • OPCRead

    ClickButtontogetlatestValuefromOPCServer

    MatrikonOPCServer/OPCExplorer VisualStudioApp

  • ReadfromOPCServerusingVisualStudiousingNationalInstruments;usingNationalInstruments.Net;stringopcUrl;doubleopcValue;

    opcUrl ="opc://localhost/Matrikon.OPC.Simulation/Bucket Brigade.Real4";

    DataSocketdataSocket =newDataSocket();

    if(dataSocket.IsConnected)dataSocket.Disconnect();

    dataSocket.Connect(opcUrl, AccessMode.Read);dataSocket.Update();opcValue =Convert.ToDouble(dataSocket.Data.Value);

    Note!ThisCodeSnippet readsonly onevalueonce,you canusee.g.aTimer inordertoreadvalues atspecific intervals.

  • usingNationalInstruments;usingNationalInstruments.Net;usingSystem;usingSystem.Windows.Forms;

    namespaceOPC_Read{public partialclassForm1:Form{DataSocketdataSocket=newDataSocket();

    public Form1(){InitializeComponent();

    stringopcUrl;opcUrl ="opc://localhost/MATRIKON.OPC.Simulation/Bucket Brigade.Real4";

    if(dataSocket.IsConnected)dataSocket.Disconnect();

    dataSocket.Connect(opcUrl, AccessMode.Read);}

    privatevoidbtnReadOpc_Click(object sender, EventArgse){dataSocket.Update();

    txtReadOpcValue.Text =dataSocket.Data.Value.ToString();}

    }}

  • OPCWriteExample

    Hans-PetterHalvorsen,M.Sc.

  • WriteOPCExampleMatrikonOPCServer/OPCExplorer

    VisualStudioApp

  • usingNationalInstruments;usingNationalInstruments.Net;stringopcUrl;doubleopcValue;

    opcUrl ="opc://localhost/Matrikon.OPC.Simulation/Bucket Brigade.Real4";

    DataSocketdataSocket =newDataSocket();

    if(dataSocket.IsConnected)dataSocket.Disconnect();

    dataSocket.Connect(opcUrl, AccessMode.Write);

    opcValue=Convert.ToDouble(txtWriteOpcValue.Text);dataSocket.Data.Value=opcValue;dataSocket.Update

Recommended

View more >