Channel list from SQL


Recommended Posts

Hi,

I have problem with add channels from seq. I write code like below;

channel.ClearAll()

channel.Add("Test215",0,"A/D",0,21)

channel.Add("Test216",0,"D/A",0,22)

channel.Add("Test217",0,"String",0,23)

Channel.Restart()

But channel type always "A to D". it is not changing. Also history is 3600. I want to change that also 1 with add function.

My Sql table like below;

Valf1 99.5

Valf2 89.5

Valf3 79.5

Valf4 69.5

Valf5 59.5

I want to read that table from SQL and create channel name with values from sql server.

Link to comment
Share on other sites

The I/O type must match EXACTLY what it says in the channel table. So, you have to put D to A, not D/A, etc. If it doesn't match, it uses the first I/O type. As for changing history, once you create the channel, you can edit its parameters programatically. The Add() function is designed to require only the minimum to create a channel to keep the # of parameters reasonable.

Link to comment
Share on other sites

You can see my code. and also channel list.

1- I want to add all channel IO type string.

2- I want to be history lenght 1 for all channel

dbase = db.Open("ScadaTest")

try

qr = db.QueryToClass(dbase,"select * from CSVTest13")

helper = qr.Name

helper2 = qr.ChValue

catch()

System.ErrorMessage(strLastError)

endcatch

db.close(dbase)

global ddd=111

channel.ClearAll()

for(private.count=0, count<NumRows(helper), count++)

channel.Add(helper[count],0,"String",count,count)

Execute(helper[count]+".AddValue(helper2[count])")

ddd=count

endfor

Channel.Restart()

post-1585-1323764808_thumb.jpg

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.