- 프로젝트 만들기
- 개체 및 변수 참조
- 프로젝트 확장
임의의 값을 삽입하기 위한 NetLogic 개발
이 NetLogic 스크립트는 데이터베이스의
Table1
테이블에 임의의 값을 삽입합니다.필수 구성 요소
기본 외부 코드 편집기를 설정합니다. 기본 코드 편집기 설정 항목을 참조하십시오.
- NetLogic을 개발하려면
- 프로젝트 보기에서데이터 저장소폴더를 확장합니다.
- 데이터베이스를 마우스 오른쪽 버튼으로 클릭하고을 선택합니다.
- NetLogic 위로 마우스를 가져가서을 선택하고EmbeddedDatabase1NetLogic을 입력합니다.
- NetLogic을 두 번 클릭합니다.외부 코드 편집기가 열립니다.
- 코드 편집기에서 기존 코드를 다음 코드로 바꿉니다.#region Using directives using System; using FTOptix.HMIProject; using FTOptix.NetLogic; using FTOptix.Store; #endregion public class EmbeddedDatabase1NetLogic : BaseNetLogic { public override void Start() { // Insert code to be executed when the user-defined logic is started } public override void Stop() { // Insert code to be executed when the user-defined logic is stopped } [ExportMethod] public void InsertRandomValues (){ // Get the current project folder. var project = Project.Current; // Save the names of the columns of the table to an array string[] columns = { "Column1", "Column2", "Column3" }; // Create and populate a matrix with values to insert into the odbc table var rawValues = new object[1000, 3]; Random randomNumber = new Random (); for (UInt16 i = 0; i < 1000; ++i) { // Column1 rawValues[i, 0] = i; // Column2 rawValues[i, 1] = randomNumber.Next(0, 5000); // Column3 rawValues[i, 2] = randomNumber.NextDouble() * 5000; } var myStore = LogicObject.Owner as Store; // Get Table1 from myStore var table1 = myStore.Tables.Get<Table>("Table1"); // Insert values into table1 table1.Insert(columns, rawValues); } }
- 코드를 저장합니다.
의견을 작성 부탁드립니다.