Wednesday, October 19, 2016

News in ver. 3.2.0

- CommunicationView for Diff. Time used "Int" filter
- Update DataGridExtension 1.0.33 -> 1.0.44
- Update MahApps.Metro  1.3.0 -> 1.4.0
- Update SQLite -> 1.0.102 -> 1.0.103
- Update OxyPlot -> 1.0.0.2182 -> 2.0.0.0933
- Update Newtonsoft.Json 9.0.1 -> 9.0.2
- Added folder with logs for catching information about anhandled uxception [Fenix Directory]\\Logs

Wednesday, September 7, 2016

SimpleHMI by Html Page - Part2

On previous post we were show how create custom view for our project. Now its time to add view measurement point. I would like to use Modbus simulator and use it like container for variable and communication. Logic will be implement on Fenix by C# script.

5. Simulation Logic

We will use 7 variables and and script for logic simulation. Picture below showing created Tags. Connection is now created for simulation Mod_RSim.



Listing below "Script.cs" its added to Scripts Node

using System;
using ProjectDataLib;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class Script : ScriptModel
{
    public override void Start()
    {
    }
    public override void Stop()
    {      
    }
    public override void Cycle()
    {     
     //When Sw1 is "1" Turn on Light1 if not turn off 
     if((bool)GetTag("Sw1"))
      SetTag("Light1",true);
        else
      SetTag("Light1",false);
                           
     //When Sw2 is "1" Turn on Light2 if not turn off 
     if((bool)GetTag("Sw2"))
      SetTag("Light2",true);
        else
      SetTag("Light2",false);
                                
     //When Sw3 is "1" Turn on Light3 if not turn off 
     if((bool)GetTag("Sw3"))
      SetTag("Light3",true);
        else
      SetTag("Light3",false);
               
        //Temperature1 simulation. Random values between 0 - 20
        Random rd = new Random();
        float temp1 = (float)(rd.NextDouble() * 20.0);
        SetTag("Temperature1",temp1);          
    }
}

6. Add variable to Html

Code with description:

   <script>
    $(document).ready(function fcElementProp(){ 
              
    $('#temp1').css({
       position: 'absolute',
       top: '200px',
       left: '290px'
   });
   
   $('#L1').css({
       position: 'absolute',
       top: '180px',
       left: '440px',
       background: 'green',
       width: '40px',
       height: '40px'
   });
   
   $('#L2').css({
       position: 'absolute',
       top: '220px',
       left: '140px',
       background: 'green',
       width: '40px',
       height: '40px'
   });
   
   $('#L3').css({
       position: 'absolute',
       top: '410px',
       left: '170px',
       background: 'green',
       width: '40px',
       height: '40px'
   });
   
   //Sw1 click handler
   $( "#sw1" ).click(function() {
   
   //invoke only if Tags isnt empty
          if (!$.isEmptyObject(Tags))
    {
       if(Tags["Sw1"].value)
       {
          $.post("Tag/Sw1/Value/0",function(data){ 
             alert("Data Changed");
             });
              }
              else
              {
                $.post("Tag/Sw1/Value/1",function(data){
                  alert("Data Changed");
             });
              }
    }   
   });
   
      //Sw2 click handler
   $( "#sw2" ).click(function() {
   
     //invoke only if Tags isnt empty
          if (!$.isEmptyObject(Tags))
    {
       if(Tags["Sw2"].value)
       {
          $.post("Tag/Sw2/Value/0",function(data){ 
             alert("Data Changed");
             });
              }
              else
              {
                $.post("Tag/Sw2/Value/1",function(data){
                  alert("Data Changed");
             });
              }
    }   
   });
   
      //Sw3 click handler
   $( "#sw3" ).click(function() {
   
     //invoke only if Tags isnt empty
          if (!$.isEmptyObject(Tags))
    {
       if(Tags["Sw3"].value)
       {
          $.post("Tag/Sw3/Value/0",function(data){ 
             alert("Data Changed");
             });
              }
              else
              {
                $.post("Tag/Sw3/Value/1",function(data){
                  alert("Data Changed");
             });
              }
    }   
   });
   
    });
         
   $(document).ready(function fcMainCycle(){ 
   
       //Wait if buffor is empty
       if ($.isEmptyObject(Tags))
         $("#temp1").html("---");
       else 
       {
         $("#temp1").html(Tags["Temperature1"].formattedValue + " ℃");
         
         //Light1
         if(Tags["Light1"].value)
           $('#L1 ').css("background","red");
         else
           $('#L1 ').css("background","green");
           
         //Light2
         if(Tags["Light2"].value)
           $('#L2 ').css("background","red");
         else
           $('#L2 ').css("background","green");
           
          //Light3 
         if(Tags["Light3"].value)
           $('#L3 ').css("background","red");
         else
           $('#L3 ').css("background","green");    
       }
     
     //Cycle every 1000ms
     setTimeout(fcMainCycle,500); 
    });
   </script>

7. Browser View

Website allow you to use 3 switches SW1,2,3 to turn on or turn off Lights L1,2,3, Additionally random temperature is showing.


Link for download


Wednesday, August 31, 2016

SimpleHMI by Html Page - Part1

The article was created to show how create simple control based on Web Page. Fenix can share data from Modbus or S7 devices in WebBrowsers. During project creation you can include standard web template to project with all important libraries. Template is used by Fenix Server which work from one side like WebSerwer ans second side like Modbus or S7 client. We will prepare simple example how control light and look on temperature in intelligent home system.

1. Create project name "SimpleHMI"

- Open Fenix
- Click on ^File->New^, <Add Project> window will appear. Type in [Project Name] "SimpleHMI"
Important is to that during creation option [Apply Http Templates] must be checked. Fenix will create structure below.




















2. Change "index.html" file

On beginning open "index.html" from ^HttpServer->Index.html->Open^ and delete all data between <style></style> and all data between <body></body>. Code will be look like picture below:

<!doctype html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
   <title>Fenix Modbus</title>   
   <script language="javascript" type="text/javascript" src="jquery-2.2.0/jquery-2.2.0.min.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.time.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.tooltip.js"></script>
   <script language="javascript" type="text/javascript" src="jquery-ui-1.11.4/jquery-ui.js"></script>  
   <script language="javascript" type="text/javascript" src="fenixlib.js"></script>
   <script language="javascript" type="text/javascript" src="script.js"></script>    
     
   <style>
   </style>

</head> 
<body>  
</body>
 
</html>

3. Add mimic like background

We were creted "bgd.jpg" this will be main mimic. We will add it like bacground in "index.html". The size of the "bgd.jpg" will be 600x600px. To add this file to project:

- Click on ^HtmlServer->Add Files->Add Existing File^
- Select right *.jpg file.
- Add code below to index.html

<!doctype html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
   <title>Fenix Modbus</title>   
   <script language="javascript" type="text/javascript" src="jquery-2.2.0/jquery-2.2.0.min.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.time.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.tooltip.js"></script>
   <script language="javascript" type="text/javascript" src="jquery-ui-1.11.4/jquery-ui.js"></script>  
   <script language="javascript" type="text/javascript" src="fenixlib.js"></script>
   <script language="javascript" type="text/javascript" src="script.js"></script>         
   <style>
    body {
  height: 600px;
  height: 600px;
        background-image: url("bgd.jpg");
        background-repeat: no-repeat;
 }
   </style>
</head> 
<body>  
</body>
 
</html>

4. Testing page in Fenix

To test work progress:
- Click on ^HttpServer->Simulation^ 
- <HttpServer> will start
- Go to WebBrowser and type in URL "localhost" or "127.0.0.1"




To be continued

Sunday, August 21, 2016

News in ver. 3.1.9

- Fenix didn't want to write data in S7 DB blocks. Repaired
- During creating Connection default parameters was given (not from windows). Repaired
- Local Help file was replaced by WebSite help.
- Siemens S7 driver all events were connected to ComunnicationView
- CommunicationView added driver name column.
- CommunicationView added amount of record in GridView
- CommunicationView added save to CSV possibility.
- CommunicaionView added save to clipboard possibility
- CommunicationView filtering data possibility (basic)
- Database CSV file export problem with coma for values. Used dot for values only.
- Update OxyPlot 1.0.0.2176 -> 1.0.0.2182
- Update MahApps.Metro 1.3.0.166  -> 1.3.0.188
- Update SC-Script.bin 3.13.2     -> 3.14
- Update TaskScheduler          2.5.20     -> 2.5.21

Wednesday, August 17, 2016

S7 Siemens to Modbus TCP/IP


In this article I will try explain how to push data from Siemens S7 plc to Modbus device. For this purpose I will use Fenix software. To carry data between drivers we will use C# script.

We will have two remote devices:
Siemens PLC [S7Plc] -> 192.168.142.134:102
Modbus Device [ModPlc] -> 192.168.142.134:502

Issue is take data from S7Plc and push to ModPlc. Assigning addresses are shown below:
Var1 DB1.DBD0  -> HoldingRegister [40001]
Var2 DB1.DBD4  -> HoldingRegister [40003]
Var3 DB1.DBD8  -> HoldingRegister [40005]
Var4 DB1.DBD12 -> HoldingRegister [40007]

Now we will create project in Fenix. Start fenix and create new project. Picture below:


Next step is to add two connections to project:


Then we will create device and tags for S7 communication:

We will do the same for Modbus communication:


When we finished you will get something similar like picture below:


When project is created we will set all important parameters. We will create script. Script will be invoked every 50 ms. We must set time default timer for script. 

1. Click on Scripts on Solution.
2. Go to Properties. Click on filed Timers
3. CustomerTimer window will appear. Change default time from 1500 to 50 ms the click OK.

Now add Timer to script to do this:

1. Click on Script.cs on Solution
2. Go to Properties and from ComboBox 03 Script choose Timer.


Now we can write script. Open script in editor and add code:


Code:
Script have 3 methotds. Start() is invoking during start of driver. Stop() is invoking during driver stop. Cycle() is invoking by Timer every 50ms. Script have access to all Tags in project and for that you can use functions:
SetTag("TagName", Value);
GetTag("TagName");

using System;
using ProjectDataLib;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class Script : ScriptModel
{

    public override void Start()
    {
    }

    public override void Stop()
    {
    }
    public override void Cycle()
    {
        var Var0 = GetTag("S7Var0");
        SetTag("ModVar0",Var0);

        var Var1 = GetTag("S7Var1");
        SetTag("ModVar1",Var1);
           
        var Var2 = GetTag("S7Var2");
        SetTag("ModVar1",Var1);
  
        var Var3 = GetTag("S7Var3");
        SetTag("ModVar3",Var3);
    }
}

And Start communication:

1. Click on Solution on Example1
2. Click on TableView
3. Click to start all communication drivers.


Monday, July 25, 2016

News in ver. 3.1.8


- Database thread strongly overloaded main thread. UI was hanging. Repaired.
- Psf binary files not supported.
- Zedgraph.dll removed from project (that was part of old solution)

Monday, July 18, 2016

News in ver. 3.1.7

1. New project file format XML (*.psx)

Since 3.1.7 Felix will not support binary file (*.psf). Only open will be possible. Provided new file which base on XML format (*.psx). Fenix project file now is ready to edit in 3rd party editors. Below is example how file looks in side.


2. Added Color rectangle in TreeView.

All Tags and InternalTag will have small rectangle with color correspond to TableView and Properties. Rectangles will simplify identification and work with Tags


3. Updates 3rd party libraries

- Update OxyPlot 1.0.0.2175      ->     1.0.0.2176
- Update SC-Script.bin 3.12.2.1              ->     3.13.2
- Update Newtonsoft.Json 9.0.1-beta              ->     9.0.1
- Update System.Data.Sql 1.0.101      ->     1.0.102


4. Repaired Bugs 

Removed problem with names in Tag and InTag windows.
Removed automatic save during close.
Removed bugs related with ChartView and saving param.
TableView Tag value invisible when row was selected.
Problem with database during usage Tag scripts.