{"id":1673,"date":"2014-01-13T11:55:51","date_gmt":"2014-01-13T10:55:51","guid":{"rendered":"http:\/\/www.objectis-software.com\/support\/?p=1673"},"modified":"2021-01-26T10:51:37","modified_gmt":"2021-01-26T09:51:37","slug":"ocf-client-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.objectis-software.com\/support\/ocf-client-cheat-sheet\/","title":{"rendered":"Ocf Client (OcfApiClient)&#8217;s cheat sheet"},"content":{"rendered":"\n<p>Welcome on the Ocf Client (Ocf Api)&#8217;s Cheat Sheet. This post will help you to get started Ocf Client.<\/p>\n\n\n\n<p>You can also <a href=\"http:\/\/www.objectis-software.com\/support\/download\/user-guides\/Objectis_Cheat_Sheet_-_OcfApi_1.1.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">get the PDF here<\/a>.<\/p>\n\n\n\n<p>Here is the contents:<\/p>\n\n\n\n<ol type=\"1\"><li>Ocf Clients for Embedded\n<ol type=\"1\">\n<li>Create a client for embedded system (UDP)<\/li>\n<li>Create a client for embedded system (COM)<\/li>\n<\/ol>\n<\/li><li>Ocf Clients for .NET\n<ol type=\"1\">\n<li>Create a native client for .NET application<\/li>\n<li>Create a secure native client for .NET application (communication with AES encryption)<\/li>\n<\/ol>\n<\/li><li>Ocf Clients for ADS PLC\n<ol type=\"1\">\n<li>Create an ADS client for PLC application<\/li>\n<\/ol>\n<\/li><li>Retrieve data thanks to Ocf<\/li><li>Register the licenses<\/li><\/ol>\n\n\n\n<p>Let&#8217;s begin!<\/p>\n\n\n\n<h2>Ocf  Clients for Embedded<\/h2>\n\n\n\n<h3>Create a client for embedded system (UDP)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nPrototype : \npublic static dynamic CreateOcfEmbeddedUdpClient(\u000bstring hostName, int port, int timeout);\n\nSample : \ndynamic client = OcfApi.CreateOcfWcfClient(\u000b&quot;127.0.0.1&quot;, 10000, 200);\n<\/pre><\/pre>\n\n\n\n<h3>Create a client for embedded system (COM)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nPrototype : \npublic static dynamic CreateOcfEmbeddedComClient(\u000bstring portName, SerialDataBaudRate rate, int timeout, SerialDataLength length = SerialDataLength.DL8, Handshake handShake = Handshake.None, Parity parity = Parity.None,  StopBits stopBits = StopBits.One);\n\nSample : \ndynamic client = OcfApi.CreateOcfEmbeddedComClient(&quot;COM5&quot;, SerialDataBaudRate.BR19200, 1000);\n<\/pre><\/pre>\n\n\n\n<h2>Ocf Clients for .NET<\/h2>\n\n\n\n<h3>Create a native client for .NET application<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nPrototype (Udp) :\npublic static dynamic CreateOcfNativeUdpClient(string\nhostName, int port, int timeout);\n\nPrototype (Tcp) :\npublic static dynamic CreateOcfNativeTcpClient(string\nhostName, int port, int timeout);\n<\/pre><\/pre>\n\n\n\n<h3>Create a secure native client for .NET application (communication with AES encryption)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nPrototype (Udp) :\npublic static dynamic CreateOcfNativeUdpEncryptedClient(\nstring hostName, int port, string passphrase, int timeout);\n\nPrototype (Tcp) :\npublic static dynamic CreateOcfNativeTcpEncryptedClient(\nstring hostName, int port, string passphrase, int timeout);\n<\/pre><\/pre>\n\n\n\n<h2>Ocf Clients for ADS PLC<\/h2>\n\n\n\n<h3>Create an ADS client for PLC application<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nPrototype (ADS) :\npublic static dynamic CreateOcfAdsClient(string netId, int port, int timeout = DefaultTimeOut);\n\nSample :\ndynamic client = OcfApi. CreateOcfAdsClient(\u000b   &quot;192.168.10.12.1.1&quot;, 801);\n<\/pre><\/pre>\n\n\n\n<h2>Retrieve data thanks to Ocf<\/h2>\n\n\n\n<p>Get a child of the remote object model<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\ndynamic axisX = client.Robot.AxisX;\n<\/pre><\/pre>\n\n\n\n<p>Reach a property of the remote object model<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nIn C#:\nConsole.WriteLine(&quot;AxisX :&quot;, client.Robot.AxisX.Position);\nclient.Robot.AxisX.Position = 100;\n\nIn Xaml :\n&amp;amp;amp;lt;GroupBox Header=&quot;{Binding Client.Name}&quot; Margin=&quot;5&quot;&amp;amp;gt;\n<\/pre><\/pre>\n\n\n\n<p>Invoke a method of the remote object model<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nclient.PowerEnable();\n<\/pre><\/pre>\n\n\n\n<p>Manage communication errors with Ocf<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nDefine handler on unhandled exceptions :\nApplication.Current.DispatcherUnhandledException +=   CurrentDispatcherUnhandledException;\n\nManage OcfException globally :\nprivate void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)\n{\nif (e.Exception is OcfException)\nShowException(e.Exception as Exception);\n}\n<\/pre><\/pre>\n\n\n\n<h2>Register the licenses<\/h2>\n\n\n\n<p>Register a license to create a server\/client Ocf<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre class=\"brush: csharp; light: true; title: ; notranslate\" title=\"\">\nPrototype :\npublic static void RegisterLicense(\u000bstring companyName, string key)\n\nSample :\nOcfApi.RegisterLicense(&quot;CompanyName&quot;, &quot;XXXX-XXXX-XXXX-XXXX&quot;);\n<\/pre><\/pre>\n\n\n<!-- Simple Share Buttons Adder (8.4.6) simplesharebuttons.com --><div class=\"ssba-classic-2 ssba ssbp-wrap alignleft ssbp--theme-1\"><div style=\"text-align:left\"><span class=\"ssba-share-text\">Share this...<\/span><br\/><a data-site=\"facebook\" class=\"ssba_facebook_share ssba_share_link\" href=\"https:\/\/www.facebook.com\/sharer.php?t=Ocf Client (OcfApiClient)&#8217;s cheat sheet&u=https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/posts\/1673\"  target=_blank  style=\"color:; background-color: ; height: 48px; width: 48px; \" ><img src=\"https:\/\/www.objectis-software.com\/support\/wp-content\/plugins\/simple-share-buttons-adder\/buttons\/somacro\/facebook.png\" style=\"width: 35px;\" title=\"facebook\" class=\"ssba ssba-img\" alt=\"Share on facebook\" \/><div title=\"Facebook\" class=\"ssbp-text\">Facebook<\/div><\/a><a data-site=\"pinterest\" class=\"ssba_pinterest_share ssba_share_link\" href=\"https:\/\/pinterest.com\/pin\/create\/button\/?description=Ocf Client (OcfApiClient)&#8217;s cheat sheet&media=&url=https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/posts\/1673\"  target=_blank  style=\"color:; background-color: ; height: 48px; width: 48px; \" ><img src=\"https:\/\/www.objectis-software.com\/support\/wp-content\/plugins\/simple-share-buttons-adder\/buttons\/somacro\/pinterest.png\" style=\"width: 35px;\" title=\"pinterest\" class=\"ssba ssba-img\" alt=\"Share on pinterest\" \/><div title=\"Pinterest\" class=\"ssbp-text\">Pinterest<\/div><\/a><a data-site=\"twitter\" class=\"ssba_twitter_share ssba_share_link\" href=\"https:\/\/twitter.com\/intent\/tweet?text=Ocf Client (OcfApiClient)&#8217;s cheat sheet&url=https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/posts\/1673&via=\"  target=_blank  style=\"color:; background-color: ; height: 48px; width: 48px; \" ><img src=\"https:\/\/www.objectis-software.com\/support\/wp-content\/plugins\/simple-share-buttons-adder\/buttons\/somacro\/twitter.png\" style=\"width: 35px;\" title=\"twitter\" class=\"ssba ssba-img\" alt=\"Share on twitter\" \/><div title=\"Twitter\" class=\"ssbp-text\">Twitter<\/div><\/a><a data-site=\"linkedin\" class=\"ssba_linkedin_share ssba_share_link\" href=\"https:\/\/www.linkedin.com\/shareArticle?title=Ocf Client (OcfApiClient)&#8217;s cheat sheet&url=https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/posts\/1673\"  target=_blank  style=\"color:; background-color: ; height: 48px; width: 48px; \" ><img src=\"https:\/\/www.objectis-software.com\/support\/wp-content\/plugins\/simple-share-buttons-adder\/buttons\/somacro\/linkedin.png\" style=\"width: 35px;\" title=\"linkedin\" class=\"ssba ssba-img\" alt=\"Share on linkedin\" \/><div title=\"Linkedin\" class=\"ssbp-text\">Linkedin<\/div><\/a><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Welcome on the Ocf Client (Ocf Api)&#8217;s Cheat Sheet. This post will help you to get started Ocf Client. You can also get the PDF here. Here is the contents: Ocf Clients for Embedded Create a client for embedded system (UDP) Create a client for embedded system (COM) Ocf Clients for .NET Create a native client for .NET application Create a secure native client for .NET application (communication with AES encryption) Ocf Clients for ADS PLC Create an ADS client for PLC application Retrieve data thanks to Ocf Register the licenses Let&#8217;s begin! Ocf Clients for Embedded Create a client <a class=\"blog-more btn btn-xxs btn-primary\" href=\"https:\/\/www.objectis-software.com\/support\/ocf-client-cheat-sheet\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[40],"tags":[46,21,53,25,45,48,36],"_links":{"self":[{"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/posts\/1673"}],"collection":[{"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/comments?post=1673"}],"version-history":[{"count":67,"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/posts\/1673\/revisions"}],"predecessor-version":[{"id":2078,"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/posts\/1673\/revisions\/2078"}],"wp:attachment":[{"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/media?parent=1673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/categories?post=1673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.objectis-software.com\/support\/wp-json\/wp\/v2\/tags?post=1673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}