Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

마크베이스 태그 테이블 활용

...

태그 테이블의 세부 아키텍처

...

Image Removed

...

그리고 사용자가 원하는 경우 위의 , 3가지 컬럼에 연속되는 부가 사용자 확장 컬럼을 추가할 수 있도록 설계되어 있어, 비즈니스 영역에 따라 다양한 스키마를 생성할 수 있다.

...

Code Block
languagesql
SELECT DATE_TRUNC('second', time, 30) time, avg(value) avg FROM
(
SELECT /*+ ROLLUP(TAG, sec) */ time, value
FROM TAG WHERE name = 'EQ8^TAG8287' AND time between to_date('2018-01-01 12:00:00')
and to_date('2018-01-01 12:59:59')
) group by time order by time;

위의 질의는 테그 이름이 “EQ8^TAG8287” 인 센서의 1 시간 범위의 데이터에서 30초 평균 레코드 총 120개를 얻어내는 것이다.

메타 테이블

메타(META) 테이블은 Sensor Storage 에 저장될 태그의 이름 및 부가 메타 정보를 저장하는 별도의 테이블이다.

이 테이블명은 _tag_meta로 명명되고, 사용자는 이 테이블에 대해 명시적으로 INSERT를 통해 태그의 메타 정보를 생성할 수 있다 . 이뿐만 아니라, 사용자는 이 테이블을 통해 태그 이름에 대한 생성뿐만 아니라, 수정, 삭제도 가능하다. 또한, 사용자 편의를 위해 마크베이스의 APPEND 프로토콜을 사용해서 데이터를 입력하는 경우에는 자동으로 태그 명을 생성하는 기능도 포함되어 있다. 그러나 현재 SQL 구문은 INSERT를 통해서 태그 테이블에 데이터를 입력하는 경우에는 자동으로 태그 이름을 생성해 주지는 않는다( Machbase 6.0에서 지원 예정).

...

Image Removed

...

Image Removed

...

Code Block
$ dir
C:\Machbase-5.5\TagTutorial\edu_2_plc
2019-03-06 오후 02:40 107 1_create_tag.sql # 태그 테이블 생성
2019-03-06 오후 02:40 31 2_load_meta.bat # 태그 이름 로딩
2019-03-06 오후 02:40 32 2_load_meta.sh
2019-03-06 오후 02:40 162 2_tag_meta.csv # 태그 이름 데이터
2019-03-06 오후 02:40 263 3_create_plc_tag_table.sql # 로그 테이블
2018-08-14 오후 05:15 372,389,876 4_plc_tag.csv # 데이터
2019-03-06 오후 02:40 90 4_plc_tag_load.bat # Log à Tag
2019-03-06 오후 02:40 93 4_plc_tag_load.sh
2019-03-06 오후 02:40 1,123 5_plc_to_tag.sql # insert-select

태그 테이블 생성 및 태그 메타 로딩

...

Code Block
$ machsql -s 127.0.0.1 -u sys -p manager -f 1_create_tag.sql
=================================================================
Machbase Client Query Utility
Release Version 5.5.0.official
Copyright 2014 MACHBASE Corporation or its subsidiaries.
All Rights Reserved.
=================================================================
MACHBASE_CONNECT_MODE=INET, PORT=5656
Type 'help' to display a list of available commands.
Mach> create tagdata table tag (name varchar(32) primary key, time datetime basetime, value double
summarized);
Executed successfully.
Elapsed time: 3.032
$type 2_tag_meta.csv
MTAG_V00
MTAG_V01
MTAG_C00
MTAG_C01
MTAG_C02
MTAG_C03
MTAG_C04
MTAG_C05
MTAG_C06
MTAG_C07
MTAG_C08
MTAG_C09
MTAG_C10
MTAG_C11
MTAG_C12
MTAG_C13
MTAG_C14
MTAG_C15
$ tagmetaimport -d 2_tag_meta.csv
Import time : 0 hour 0 min 0.340 sec
Load success count : 18
Load fail count : 0

...

Code Block
$ machsql -s 127.0.0.1 -u sys -p manager -f 3_create_plc_tag_table.sql
=================================================================
Machbase Client Query Utility
Release Version 5.5.0.official
Copyright 2014 MACHBASE Corporation or its subsidiaries.
All Rights Reserved.
=================================================================
MACHBASE_CONNECT_MODE=INET, PORT=5656
Type 'help' to display a list of available commands.
Mach> create table plc_tag_table(
tm datetime,
V0 DOUBLE ,
V1 DOUBLE ,
C0 DOUBLE ,
C1 DOUBLE ,
C2 DOUBLE ,
C3 DOUBLE ,
C4 DOUBLE ,
C5 DOUBLE,
C6 DOUBLE ,
C7 DOUBLE ,
C8 DOUBLE ,
C9 DOUBLE ,
C10 DOUBLE ,
C11 DOUBLE ,
C12 DOUBLE ,
C13 DOUBLE ,
C14 DOUBLE ,
C15 DOUBLE
);
Created successfully.
Elapsed time: 0.087
Warning

주의할 점은 이 테이블은 로그 테이블 타입이라는 것이다(파일명 때문에 헷갈리지 않도록 하자). 마크베이스에서는 별도의 테이블 지정자를 명시하지 않으면, 로그 테이블로 생성된다.

...

Code Block
$ 4_plc_tag_load.bat
$ machloader -t plc_tag_table -i -d 4_plc_tag.csv -F "tm YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn"
-----------------------------------------------------------------
Machbase Data Import/Export Utility.
Release Version 5.5.0.official
Copyright 2014, MACHBASE Corporation or its subsidiaries.
All Rights Reserved.
-----------------------------------------------------------------
NLS : US7ASCII EXECUTE MODE : IMPORT
TARGET TABLE : plc_tag_table DATA FILE : 4_plc_tag.csv
IMPORT MODE : APPEND FIELD TERM : ,
ROW TERM : \n ENCLOSURE : "
ESCAPE : \ ARRIVAL_TIME : FALSE
ENCODING : NONE HEADER : FALSE
CREATE TABLE : FALSE
Progress bar Imported records Error records
============================== 2000000 0
Import time : 0 hour 0 min 26.544 sec
Load success count : 2000000
Load fail count : 0

...

Code Block
insert into tag select 'MTAG_V00', tm, v0 from plc_tag_table;
insert into tag select 'MTAG_V01', tm, v1 from plc_tag_table;
insert into tag select 'MTAG_C00', tm, c0 from plc_tag_table;
insert into tag select 'MTAG_C01', tm, c1 from plc_tag_table;
insert into tag select 'MTAG_C02', tm, c2 from plc_tag_table;
insert into tag select 'MTAG_C03', tm, c3 from plc_tag_table;
insert into tag select 'MTAG_C04', tm, c4 from plc_tag_table;
insert into tag select 'MTAG_C05', tm, c5 from plc_tag_table;
insert into tag select 'MTAG_C06', tm, c6 from plc_tag_table;
insert into tag select 'MTAG_C07', tm, c7 from plc_tag_table;
insert into tag select 'MTAG_C08', tm, c8 from plc_tag_table;
insert into tag select 'MTAG_C09', tm, c9 from plc_tag_table;
insert into tag select 'MTAG_C10', tm, c10 from plc_tag_table;
insert into tag select 'MTAG_C11', tm, c11 from plc_tag_table;
insert into tag select 'MTAG_C12', tm, c12 from plc_tag_table;
insert into tag select 'MTAG_C13', tm, c13 from plc_tag_table;
insert into tag select 'MTAG_C14', tm, c14 from plc_tag_table;
insert into tag select 'MTAG_C15', tm, c15 from plc_tag_table;

...

Code Block
$ machsql -s 127.0.0.1 -u sys -p manager -f 5_plc_to_tag.sql
=================================================================
Machbase Client Query Utility
Release Version 5.5.0.official
Copyright 2014 MACHBASE Corporation or its subsidiaries.
All Rights Reserved.
=================================================================
MACHBASE_CONNECT_MODE=INET, PORT=5656
Type 'help' to display a list of available commands.
Mach> insert into tag select 'MTAG_V00', tm, v0 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 4.898
Mach> insert into tag select 'MTAG_V01', tm, v1 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 5.577
Mach> insert into tag select 'MTAG_C00', tm, c0 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.327
Mach> insert into tag select 'MTAG_C01', tm, c1 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.445
Mach> insert into tag select 'MTAG_C02', tm, c2 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.898
Mach> insert into tag select 'MTAG_C03', tm, c3 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.078
Mach> insert into tag select 'MTAG_C04', tm, c4 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.799
Mach> insert into tag select 'MTAG_C05', tm, c5 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.210
Mach> insert into tag select 'MTAG_C06', tm, c6 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 9.232
Mach> insert into tag select 'MTAG_C07', tm, c7 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.398
Mach> insert into tag select 'MTAG_C08', tm, c8 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.432
Mach> insert into tag select 'MTAG_C09', tm, c9 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.734
Mach> insert into tag select 'MTAG_C10', tm, c10 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.692
Mach> insert into tag select 'MTAG_C11', tm, c11 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 8.628
Mach> insert into tag select 'MTAG_C12', tm, c12 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 8.229
Mach> insert into tag select 'MTAG_C13', tm, c13 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 9.517
Mach> insert into tag select 'MTAG_C14', tm, c14 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.231
Mach> insert into tag select 'MTAG_C15', tm, c15 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.830

...

Image Removed

...

개요

...

Image Removed

...

Code Block
$ dir
C 드라이브의 볼륨: Windows
볼륨 일련 번호: F588-65A4
C:\Machbase-5.5\TagTutorial\edu_3_plc_stream 디렉터리
2019-03-06 오후 02:40 <DIR> .
2019-03-06 오후 02:40 <DIR> ..
2019-03-06 오후 02:40 107 1_create_tag.sql
2019-03-06 오후 02:40 31 2_load_meta.bat
2019-03-06 오후 02:40 32 2_load_meta.sh
2019-03-06 오후 02:40 162 2_tag_meta.csv
2019-03-06 오후 02:40 263 3_create_plc_tag_table.sql
2019-03-06 오후 02:40 2,313 4_plc_stream_tag.sql
2019-03-06 오후 02:40 89,082,205 5_plc_tag.zip
2019-03-06 오후 02:40 90 5_plc_tag_load.bat
2019-03-06 오후 02:40 93 5_plc_tag_load.sh
9 개 파일 89,085,296 바이트
2 개 디렉터리 43,790,446,592 바이트 남음

...

이 스트림이 하는 일은 로그 테이블 plc_tag_table 테이블에 데이터가 입력되는 순간 각 스트림이 동작하면서 자신의 데이터를 태그 테이블에 실시간으로 데이터를 입력하는 것이다. 아래는 실제 스트림을 등록하고, 이를 실행하는 파일 4_plc_stream_tag.sql의 내용이다.

Code Block
# 스트림 객체를 생성한다. 아직 동작중은 아님.
EXEC STREAM_CREATE(event_v0, 'insert into tag select ''MTAG_V00'', tm, v0 from plc_tag_table;');
EXEC STREAM_CREATE(event_v1, 'insert into tag select ''MTAG_V00'', tm, v1 from plc_tag_table;');
EXEC STREAM_CREATE(event_c0, 'insert into tag select ''MTAG_C00'', tm, c0 from plc_tag_table;');
EXEC STREAM_CREATE(event_c1, 'insert into tag select ''MTAG_C01'', tm, c1 from plc_tag_table;');
EXEC STREAM_CREATE(event_c2, 'insert into tag select ''MTAG_C02'', tm, c2 from plc_tag_table;');
EXEC STREAM_CREATE(event_c3, 'insert into tag select ''MTAG_C03'', tm, c3 from plc_tag_table;');
EXEC STREAM_CREATE(event_c4, 'insert into tag select ''MTAG_C04'', tm, c4 from plc_tag_table;');
EXEC STREAM_CREATE(event_c5, 'insert into tag select ''MTAG_C05'', tm, c5 from plc_tag_table;');
EXEC STREAM_CREATE(event_c6, 'insert into tag select ''MTAG_C06'', tm, c6 from plc_tag_table;');
EXEC STREAM_CREATE(event_c7, 'insert into tag select ''MTAG_C07'', tm, c7 from plc_tag_table;');
EXEC STREAM_CREATE(event_c8, 'insert into tag select ''MTAG_C08'', tm, c8 from plc_tag_table;');
EXEC STREAM_CREATE(event_c9, 'insert into tag select ''MTAG_C09'', tm, c9 from plc_tag_table;');
EXEC STREAM_CREATE(event_c10, 'insert into tag select ''MTAG_C10'', tm, c10 from
plc_tag_table;');
EXEC STREAM_CREATE(event_c11, 'insert into tag select ''MTAG_C11'', tm, c11 from
plc_tag_table;');
EXEC STREAM_CREATE(event_c12, 'insert into tag select ''MTAG_C12'', tm, c12 from
plc_tag_table;');
EXEC STREAM_CREATE(event_c13, 'insert into tag select ''MTAG_C13'', tm, c13 from
plc_tag_table;');
EXEC STREAM_CREATE(event_c14, 'insert into tag select ''MTAG_C14'', tm, c14 from
plc_tag_table;');
EXEC STREAM_CREATE(event_c15, 'insert into tag select ''MTAG_C15'', tm, c15 from
plc_tag_table;');
# 스트림 객체를 구동시킨다. 이것이 구동되면, plc_tag_table 테이블에 데이터가 입력되는 순간
태그 테이블로 데이터를 입력한다.
EXEC STREAM_START(event_v0);
EXEC STREAM_START(event_v1);
EXEC STREAM_START(event_c0);
EXEC STREAM_START(event_c1);
EXEC STREAM_START(event_c2);
EXEC STREAM_START(event_c3);
EXEC STREAM_START(event_c4);
EXEC STREAM_START(event_c5);
EXEC STREAM_START(event_c6);
EXEC STREAM_START(event_c7);
EXEC STREAM_START(event_c8);
EXEC STREAM_START(event_c9);
EXEC STREAM_START(event_c10);
EXEC STREAM_START(event_c11);
EXEC STREAM_START(event_c12);
EXEC STREAM_START(event_c13);
EXEC STREAM_START(event_c14);
EXEC STREAM_START(event_c15);

...

Code Block
$ machsql -s 127.0.0.1 -u sys -p manager -f 4_plc_stream_tag.sql
=================================================================
Machbase Client Query Utility
Release Version 5.5.0.official
Copyright 2014 MACHBASE Corporation or its subsidiaries.
All Rights Reserved.
=================================================================
MACHBASE_CONNECT_MODE=INET, PORT=5656
Type 'help' to display a list of available commands.
Mach> EXEC STREAM_CREATE(event_v0, 'insert into tag select ''MTAG_V00'', tm, v0 from
plc_tag_table;');
Executed successfully.
Elapsed time: 0.011
Mach> EXEC STREAM_CREATE(event_v1, 'insert into tag select ''MTAG_V00'', tm, v1 from
plc_tag_table;');
Executed successfully.
Elapsed time: 0.006
Mach> EXEC STREAM_CREATE(event_c0, 'insert into tag select ''MTAG_C00'', tm, c0 from
plc_tag_table;');
Executed successfully.
Elapsed time: 0.010
Mach> EXEC STREAM_CREATE(event_c1, 'insert into tag select ''MTAG_C01'', tm, c1 from
plc_tag_table;');
Executed successfully.
Elapsed time: 0.006
..... 생략 ....
Mach> EXEC STREAM_CREATE(event_c15, 'insert into tag select ''MTAG_C15'', tm, c15 from
plc_tag_table;');
Executed successfully.
Elapsed time: 0.006
Mach> EXEC STREAM_START(event_v0);
Executed successfully.
Elapsed time: 0.012
Mach> EXEC STREAM_START(event_v1);
Executed successfully.
..... 생략 ....
Mach> EXEC STREAM_START(event_c15);
Executed successfully.
Elapsed time: 0.012

...

Code Block
Mach> desc v$streams;
desc v$streams;
[ COLUMN ]
----------------------------------------------------------------
NAME TYPE LENGTH
----------------------------------------------------------------
NAME varchar 100
LAST_EX_TIME datetime 31
TABLE_NAME varchar 100
END_RID long 20
STATE varchar 10
QUERY_TXT varchar 2048
ERROR_MSG varchar 2048
Mach>select name, state from v$streams;
name state
-------------------------------------------------------------------
EVENT_V0 RUNNING
EVENT_V1 RUNNING
EVENT_C0 RUNNING
EVENT_C1 RUNNING
EVENT_C2 RUNNING
EVENT_C3 RUNNING
EVENT_C4 RUNNING
EVENT_C5 RUNNING
EVENT_C6 RUNNING
EVENT_C7 RUNNING
EVENT_C8 RUNNING
EVENT_C9 RUNNING
EVENT_C10 RUNNING
EVENT_C11 RUNNING
EVENT_C12 RUNNING
EVENT_C13 RUNNING
EVENT_C14 RUNNING
EVENT_C15 RUNNING
[18] row(s) selected.
Elapsed time: 0.013
Mach>

...

Code Block
Mach> select name, state, end_rid from v$streams;
name state end_rid
-----------------------------------------------------------------------------------------------------------------------
EVENT_V0 RUNNING 909912
EVENT_V1 RUNNING 1584671
EVENT_C0 RUNNING 1312416
EVENT_C1 RUNNING 1268520
EVENT_C2 RUNNING 1636800
EVENT_C3 RUNNING 1197840
EVENT_C4 RUNNING 622728
EVENT_C5 RUNNING 972780
EVENT_C6 RUNNING 1021512
EVENT_C7 RUNNING 1287474
EVENT_C8 RUNNING 826956
EVENT_C9 RUNNING 1639032
EVENT_C10 RUNNING 725954
EVENT_C11 RUNNING 1511436
EVENT_C12 RUNNING 531079
EVENT_C13 RUNNING 1004400
EVENT_C14 RUNNING 741768
EVENT_C15 RUNNING 746604
[18] row(s) selected.
Elapsed time: 0.004

...

Code Block
# 전체 레코드가 증가하는 것을 확인할 수 있다.
Mach> select count(*) from TAG;
count(*)
-----------------------
16775979
[1] row(s) selected.
Elapsed time: 0.000
Mach>
Mach> select count(*) from TAG;
count(*)
-----------------------
17609187
[1] row(s) selected.
Elapsed time: 0.000
Mach> select count(*) from TAG;
count(*)
-----------------------
18238357
[1] row(s) selected.
Elapsed time: 0.000
Mach> select count(*) from TAG;
count(*)
-----------------------
18718622
[1] row(s) selected.
Elapsed time: 0.000

...

Code Block
Mach> select name, state, end_rid from v$streams;
name state end_rid
-----------------------------------------------------------------------------------------------------------------------
EVENT_V0 RUNNING 2000000
EVENT_V1 RUNNING 2000000
EVENT_C0 RUNNING 2000000
EVENT_C1 RUNNING 2000000
EVENT_C2 RUNNING 2000000
EVENT_C3 RUNNING 2000000
EVENT_C4 RUNNING 2000000
EVENT_C5 RUNNING 2000000
EVENT_C6 RUNNING 2000000
EVENT_C7 RUNNING 2000000
EVENT_C8 RUNNING 2000000
EVENT_C9 RUNNING 2000000
EVENT_C10 RUNNING 2000000
EVENT_C11 RUNNING 2000000
EVENT_C12 RUNNING 2000000
EVENT_C13 RUNNING 2000000
EVENT_C14 RUNNING 2000000
EVENT_C15 RUNNING 2000000
[18] row(s) selected.

...

Code Block
Mach> select count(*) from TAG;
count(*)
-----------------------
36000000
[1] row(s) selected.
Elapsed time: 0.001
Mach> select min(time), max(time) from TAG;
min(time) max(time)
-------------------------------------------------------------------
2009-01-28 07:03:34 000:000:000 2009-01-28 12:36:58 020:000:000
[1] row(s) selected.
Elapsed time: 0.005
Mach>

...

개요


태그 테이블은 일반적인 센서 데이터가 저장된 파일의 구조 형태를 로딩할 수 있다.

가장 흔히 볼 수 있는 형태의 텍스트 저장 파일은 아무런 설명 없이, (콤마)나 나뉘어진 다수의 숫자형 값을 그냥 나열한 무작위의 파일 내용인 <값,값,값><값,값,값><반복..> 형태가 대표적이고, 시간을 포함한 파일의 경우에는 <시간,값,값,값> <시간, 값,값,값><반복..>이 있다.

이런 파일의 데이터는 PLC (programmable Logic Controller)라고 불리는 장비에서 1개 이상의 센서 값을 지속적으로 입력된 데이터를 오랜 기간동안 수집했을 경우에 만들어진다. 아래의 사진이 그 예이다.


Image Added


이제 이 파일을 어떻게 마크베이스의 태그 테이블로 한꺼번에 배치 형태로 로딩하겠다.



Table of Contents

데이터 변환 순서도


Image Added


위의 그림에서 볼 수 있듯이 원시 CSV 파일을 마크베이스의 로그 테이블로 한꺼번에 로딩을 한 이후, 이를 태그 테이블로 변환할 것이다.

태그 테이블 생성 및 태그 메타 로딩


아래와 같이 태그 테이블을 생성하고 tagmetaimport라는 도구를 이용해서 CSV 파일에 저장된 태그 이름(태그 메타)들을 한꺼번에 로딩한다.

Code Block
Mach> create tagdata table tag (name varchar(32) primary key, time datetime basetime, value double
summarized);
Executed successfully.
Elapsed time: 3.032

$ cat tag_meta.csv
MTAG_V00
MTAG_V01
MTAG_C00
MTAG_C01
MTAG_C02
MTAG_C03
MTAG_C04
MTAG_C05
MTAG_C06
MTAG_C07
MTAG_C08
MTAG_C09
MTAG_C10
MTAG_C11
MTAG_C12
MTAG_C13
MTAG_C14
MTAG_C15

$ tagmetaimport -d tag_meta.csv
Import time : 0 hour 0 min 0.340 sec
Load success count : 18


위와 같이 성공적으로 태그 메타 정보(이름) 18개가 로딩되었다.


PLC 데이터 로딩을 위한 테이블 생성


아래의 쿼리를 수행해 로그 테이블을 생성한다.

Code Block
create table plc_tag_table(
	tm datetime,
	V0 DOUBLE ,
	V1 DOUBLE ,
	C0 DOUBLE ,
	C1 DOUBLE ,
	C2 DOUBLE ,
	C3 DOUBLE ,
	C4 DOUBLE ,
	C5 DOUBLE,
	C6 DOUBLE ,
	C7 DOUBLE ,
	C8 DOUBLE ,
	C9 DOUBLE ,
	C10 DOUBLE ,
	C11 DOUBLE ,
	C12 DOUBLE ,
	C13 DOUBLE ,
	C14 DOUBLE ,
	C15 DOUBLE
);


Warning

주의할 점은 이 테이블은 로그 테이블 타입이라는 것이다(파일명 때문에 헷갈리지 않도록 하자). 마크베이스에서는 별도의 테이블 지정자를 명시하지 않으면, 로그 테이블로 생성된다.


PLC 데이터 로딩


아래와 같이 machloader를 사용해 200만 건의 원시 PLC 데이터가 저장된 plc_tag.csv 파일을 위에서 생성한 로그 테이블 plc_tag_table에 PLC 입력 형태로 입력한다. plc_tag.csv 파일은 첫 컬럼은 시간이며, 이후 순서대로 V0, V1, …C15 까지 컬럼이 나뉘어져 있다. 데이터의 패턴은 1초에 0~99mili second까지 약 100개의 데이터가 입력되고, 100 mili second에서 999까지는 입력이 없다가, 다음 1초 동안 동일한 패턴으로 입력된다.


Code Block
$ machloader -t plc_tag_table -i -d plc_tag.csv -F "tm YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn"
-----------------------------------------------------------------
Machbase Data Import/Export Utility.
Release Version 5.5.0.official
Copyright 2014, MACHBASE Corporation or its subsidiaries.
All Rights Reserved.
-----------------------------------------------------------------
NLS : US7ASCII EXECUTE MODE : IMPORT
TARGET TABLE : plc_tag_table DATA FILE : 4_plc_tag.csv
IMPORT MODE : APPEND FIELD TERM : ,
ROW TERM : \n ENCLOSURE : "
ESCAPE : \ ARRIVAL_TIME : FALSE
ENCODING : NONE HEADER : FALSE
CREATE TABLE : FALSE
Progress bar Imported records Error records
============================== 2000000 0
Import time : 0 hour 0 min 26.544 sec
Load success count : 2000000
Load fail count : 0




태그 메타 이름 생성 규칙


이제 태그 테이블에 데이터를 넣어서 실제로 Tag Analyzer를 통해서 데이터를 확인할 수 있도록 한다. 이를 위해서 plc_tag_table 의 정보를 모두 태그 테이블에 넣어야 하는데, 이를 위해서 insert-select 구문을 이용해서 한꺼번에 넣는다. 그리고, 각 컬럼의 값이 모든 태그 테이블의 이름과 맵핑이 되어야 하기 때문에 다음과 같이 매타 태그의 이름 정보를 미리 결정하였다.

로그 테이블의 컬럼명태그 테이블의 Name 컬럼에 입력되는 이름
V0MTAG_V00
V1MTAG_V01
C0MTAG_C00
C1MTAG_C01
...
C15MTAG_C15


태그 테이블 데이터 로딩


이제 마지막으로 실제 데이터를 태그 테이블로 로딩할 차례이다. 아래의 쿼리를 수행하면 하나씩 순차적으로 태그 테이블에 넣는다. 


Code Block
Mach> insert into tag select 'MTAG_V00', tm, v0 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 4.898
Mach> insert into tag select 'MTAG_V01', tm, v1 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 5.577
Mach> insert into tag select 'MTAG_C00', tm, c0 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.327
Mach> insert into tag select 'MTAG_C01', tm, c1 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.445
Mach> insert into tag select 'MTAG_C02', tm, c2 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.898
Mach> insert into tag select 'MTAG_C03', tm, c3 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.078
Mach> insert into tag select 'MTAG_C04', tm, c4 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.799
Mach> insert into tag select 'MTAG_C05', tm, c5 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.210
Mach> insert into tag select 'MTAG_C06', tm, c6 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 9.232
Mach> insert into tag select 'MTAG_C07', tm, c7 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 

...

Code Block
Mach> select name, state, end_rid from v$streams;
name state end_rid
---------------------------------------------------------------
EVENT_V0 RUNNING 2000001
EVENT_V1 RUNNING 2000001
EVENT_C0 RUNNING 2000001
EVENT_C1 RUNNING 2000001
EVENT_C2 RUNNING 2000001
EVENT_C3 RUNNING 2000001
EVENT_C4 RUNNING 2000001
EVENT_C5 RUNNING 2000001
EVENT_C6 RUNNING 2000001
EVENT_C7 RUNNING 2000001
EVENT_C8 RUNNING 2000001
EVENT_C9 RUNNING 2000001
EVENT_C10 RUNNING 2000001
EVENT_C11 RUNNING 2000001
EVENT_C12 RUNNING 2000001
EVENT_C13 RUNNING 2000001
EVENT_C14 RUNNING 2000001
EVENT_C15 RUNNING 2000001
[18] row(s) selected.
Elapsed time: 0.001
Mach>

...

Image Removed

아래는 1건 입력 이후 차트인데, 실제로 그래프가 올라간 것을 확인할 수 있다.

Image Removed

즉, 이는 로그 테이블에 입력된 1건의 데이터가 스트림을 통해 실시간으로 태그 테이블에 반영된 것을 나타내는 것이다.

...

6.398
Mach> insert into tag select 'MTAG_C08', tm, c8 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.432
Mach> insert into tag select 'MTAG_C09', tm, c9 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 6.734
Mach> insert into tag select 'MTAG_C10', tm, c10 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.692
Mach> insert into tag select 'MTAG_C11', tm, c11 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 8.628
Mach> insert into tag select 'MTAG_C12', tm, c12 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 8.229
Mach> insert into tag select 'MTAG_C13', tm, c13 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 9.517
Mach> insert into tag select 'MTAG_C14', tm, c14 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.231
Mach> insert into tag select 'MTAG_C15', tm, c15 from plc_tag_table;
2000000 row(s) inserted.
Elapsed time: 7.830


총 3600 만건의 데이터가 로딩된 것을 확인할 수 있다.