Thursday, August 25, 2011

61850 Learing and Practice

[1] Syscorp demo DLL
[2] Syscorp 61850 API on-line Manual
[3] Latest WinPcap download
[4] WinPcap/libpcap intro on WiKipedia
[5] Syscorp 61850 on youtube
[6] SISCO 61850 solution

NOTES FROM READING 61850 STANDARD
--------------------------------------------
1. IEC61850_QUALITY_XXXX in 61850-8-1 2004. section 8.2


Logical Device (LD)
Object representing a group of functions, each function is defined
as a logical node. A physical device consists of one or several
LDs.

Logical Node (LN)
An object defined by its data and methods. LN is the smallest
part of a function that exchanges data.

Data Object (DO)
A data object is an instance of one of the IEC 61850 Common
Data Classes, for example single point status, measured value
etc. Depending on the class, each data object has a set of
attributes for monitoring and controlling the object, for instance
value, quality and control.


Data Set (DS)
The data set is the content basis for reporting and logging. The
data set contain references to the data and data attribute values.

Report Control Block (RCB)
The report control block controls the reporting process for event
data as they occur. The reporting process continues as long as
the communication is available.



Attributes
Predefined object that contains items for controlling or retrieving
status information for the parent object. The parent object can
be the Server, a Subnetwork, or a Device object.

IEC 61850 Device (IEC 61850 IED)
Object representing a physical IEC 61850 protection and control
device. You should not have more than 30 devices per each
subnetwork.




Q&A
-------------------
1. How historical data from 61850 device are handled in 61850 stack?

2. When some LD/LN not installed how 61850 stack handle that? (new *.ICD file for each different installation?)

3. For DNP3 integration poll will find out all available points. How about 61850?





NOTES OF READING servermain.c, iec61850api.h
-------------------------------------------------
Customer need to maintain its own local data storage. 61850 stack just get
data dynamically from customer's local data stroage by loopback_read, and update customer's local data storage by loopback_write.

When there's new data updated in customer's local data storage, customer need use update() to get 61850 stack updated with new value. Then 61850 stack will do GOOSE,
buffered report, unbuffered report, sample value, log. See 61850 API user manual.


PRACTICE ENABLE LOG CONTROL
-----------------------------
When enabling log control, has to choose 'log name' and 'data set'.


PRACTICE ADD 'generic private id' WITH 5 fields
----------------------------------------------
Inside any DA, we can add 'generic private id' which will allow us to further define values of 5 fields. Those 5 fields will uniquely identify any DA ID. Thus, we use those 5 fields to interact with Syscorp 61850 stack.


PRACTICE GET DEMO RUN
-----------------------
If having -19 error reported when running ServerDemo61850.exe. Update of WinPcap to latest 4.1.2 version will solve the problem. [1]




TREE CHART OF DEMO SERVER 61850 ICD FILE
------------------------------------------









Monday, August 22, 2011

Java call C function

[1] One Pdf document 'Java call C via JNI'
[2] Sun link of using JNI
[3] Java call C on power PC
[4] Sun book of JNI
[5] JNI and JNA in Wiki
[6] JNA intro on wiki
[7] where to download jna.jar

The JNA library uses a small native library called foreign function interface library (libffi) to dynamically invoke native code. [6]



Java Native Interface[5]

The Java Native Interface has a high overhead associated with it, making it costly to cross the boundary between code running on the JVM and native code.[69][70] Java Native Access (JNA) provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation. But it comes with a cost and JNA is usually slower than JNI.[71]

Tuesday, August 9, 2011

Using Scp under windows.

[1] WinScp
[2] scp that come with putty, which is not working with DropBear SSH server.

Sunday, August 7, 2011

C Call Java function under Linux/Windows

[1] Ref from codeproject



[q.yang@localhost CTest]$ ll
total 16
-rwxr--r-- 1 q.yang developer 7298 2011-08-05 15:03 CTest.cpp
drwxr-xr-x 2 q.yang developer 4096 2011-08-08 11:31 debug
-rwxr--r-- 1 q.yang developer 838 2011-08-08 11:32 makefile
[q.yang@localhost CTest]$ echo $JAVA_HOME
/usr/java/default
[q.yang@localhost CTest]$ pwd
/home/q.yang/EclipseCDT/qywkspace/Sandbox/Sample_017_CCallJava_via_JNI/CTest
[q.yang@localhost CTest]$ cat makefile
DESTDIR = ./debug
PROGRAM = $(DESTDIR)/CCallJava
SRCDIR = ./
CC = g++
OBJS := $(addprefix $(DESTDIR)/,CTest.o)
DEBUG = -g
CFLAGS = -Wall -c $(DEBUG) -D GSN_HOST_NOT_SUPPORT_RD_CONFIG
INCL = -I ./include -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux
LIB_FLAGS = -ljvm
LD_FLAGS = -L $(JAVA_HOME)/jre/lib/i386/server/ -L $(JAVA_HOME)/jre/lib/i386/
#-----------------------------------------------
#Compile and Link Image
#------------------------------------------------
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(CC) -o $(PROGRAM) $(OBJS) -pthread $(LD_FLAGS) $(LIB_FLAGS)
$(DESTDIR)/%.o:$(SRCDIR)/%.cpp
$(CC) -c $(CFLAGS) $< -o $@ $(INCL)
#-----------------------------------------------
#Clean obj and image files.
#------------------------------------------------
clean :
rm -f $(OBJS)
rm -f $(PROGRAM)



COMPILE ALL JAVA PROGRAM
------------------------------
[q.yang@localhost TestStruct]$ javac *.java


RUN C PROGRAM TO CALL JAVA FUNCTION
------------------------------------
[q.yang@localhost Sandbox]$ tree Sample_017_CCallJava_via_JNI/
Sample_017_CCallJava_via_JNI/
|-- CTest
| |-- CTest.cpp
| |-- debug
| | |-- CCallJava
| | `-- CTest.o
| `-- makefile
|-- JavaSrc
| `-- TestStruct
| |-- ControlDetail.class
| |-- ControlDetail.java
| |-- HelloWorld.class
| |-- HelloWorld.java
| |-- ReturnData.class
| |-- ReturnData.java
| |-- WorkOrder.class
| `-- WorkOrder.java
`-- readme.txt


[q.yang@localhost CTest]$ export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/i386/server/:$JAVA_HOME/jre/lib/i386/
[q.yang@localhost CTest]$ echo $LD_LIBRARY_PATH
/usr/java/default/jre/lib/i386/server/:/usr/java/default/jre/lib/i386/

[q.yang@localhost debug]$ ./CCallJava
Struct Created in C has values:
ID:11
Name:HR-HW
IP:10.32.164.133
Port:9099
Hello World!
This is the main function in HelloWorld class

TestCall:Called from the C Program


Going to Call DisplayStruct
Structure is:
-------------------------
Name:HR-HW
IP:10.32.164.133
Port9099


Going to call DisplayStructArray From C

WorkOrders are Given hereunder:
----------------------------
<---Work Order Number:1<---
Sum_Serial_ID: 2000
Access_Number: 2878430
Action_Type: 04
Effective_Date: 25-12-2007 12:20:30 PM
Fetch_Flag: 0
Reason: Executed Successfully
Access_Source: PMS
<---Work Order Number:2<---
Sum_Serial_ID: 1000
Access_Number: 2878000
Action_Type: T4
Effective_Date: 25-12-2007 11:20:30 PM
Fetch_Flag: 0
Reason:
Access_Source: RMS
Going to return an object from java


Values Returned from Object are:
returnValue=1
Log=Successfull function call
[q.yang@localhost debug]$

Install VLC Player for ubuntu 10.10

[1] Web source Link

Command line way

You need to check that a universe mirror is listed in your /etc/apt/sources.list file.

% sudo apt-get update
% sudo apt-get install vlc vlc-plugin-pulse mozilla-plugin-vlc

Friday, August 5, 2011

Install Java SE JDK6 under Fedora 9

[1] http://www.oracle.com/technetwork/java/javase/install-linux-rpm-137089.html
[2] http://fedoraunity.org/Members/zcat/using-sun-java-instead-of-openjdk

[q.yang@localhost Download]$ ./jdk-6u26-linux-i586-rpm.bin
[q.yang@localhost Download]$ ./jdk-6u26-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u26-linux-i586.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
error: can't create transaction lock on /var/lib/rpm/__db.000
Installing JavaDB
error: can't create transaction lock on /var/lib/rpm/__db.000

Done.
[q.yang@localhost Download]$ su
Password:
[root@localhost Download]# ./jdk-6u26-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
replace jdk-6u26-linux-i586.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: jdk-6u26-linux-i586.rpm
replace sun-javadb-common-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
replace sun-javadb-core-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
replace sun-javadb-client-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
replace sun-javadb-demo-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
replace sun-javadb-docs-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
replace sun-javadb-javadoc-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Installing JavaDB
Preparing... ########################################### [100%]
1:sun-javadb-common ########################################### [ 17%]
2:sun-javadb-core ########################################### [ 33%]
3:sun-javadb-client ########################################### [ 50%]
4:sun-javadb-demo ########################################### [ 67%]
5:sun-javadb-docs ########################################### [ 83%]
6:sun-javadb-javadoc ########################################### [100%]

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....


Done.
[root@localhost Download]# exit
exit
[q.yang@localhost Download]$ java -version
java version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK Client VM (build 1.6.0-b09, mixed mode)
[q.yang@localhost Download]$


CHANGE DEFAULT JDK TO SUN INSTEAD OF OPEN JDK [2]
----------------------------------------------
[q.yang@localhost ~]$ source /etc/profile.d/sunjava.sh
[q.yang@localhost ~]$ echo $PATH
/usr/java/default/bin:/usr/java/default/bin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/bin:/usr/bin:/home/q.yang/bin:/sbin:/usr/sbin:/opt/wx/2.8/bin:/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin:/opt/codeblocks20100721-svn/bin/:/home/q.yang/CodeSourcery/arm-2010q1/bin:/opt/codeblocks20100721-svn/bin:/home/q.yang/EclipseCDT/eclipse
[q.yang@localhost ~]$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
[q.yang@localhost ~]$ cat /etc/profile.d/sunjava.sh
export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH

Wednesday, August 3, 2011

Change MAC address under Linux

[1] http://www.linuxquestions.org/questions/linux-software-2/how-to-change-mac-address-304234/

[root@localhost ltib]# ifconfig eth0 down hw ether 00:0C:F1:87:56:F8