The script below demonstrates how to use the channel group and channel manipulation commands.
from DIAdem import Application as dd
if False:
import DIAdem_CodeCompletion as dd
# --------------------------------------------------------------------
dd.LogfileDel()
print('Script "LastScript.PY')
# --------------------------------------------------------------------
def ChnRemove(oChn):
#Removes the channel oChn.
oElementList = dd.Data.GetChannels(oChn.GetReference(dd.eReferenceNameName))
dd.Data.Remove(oElementList)
def bTestDIAdemScriptEnv():
dd.Data.Root.Clear()
dd.Data.Root.Name = "bTestDIAdemScriptEnv"
oGrp = dd.Data.Root.ChannelGroups.Add("MyChnGrp1")
#print('oGrp.Name = ' + oGrp.Name)
#Create a time channel
oChnX = oGrp.Channels.Add("Time",dd.DataTypeFloat64) #dd.DataTypeFloat64, dd.DataTypeString, dd.DataTypeChnDate
dd.ChnLinGen(oChnX, 0, 500, 100, 's')
#print(oChnX.GetReference(dd.eRefTypeNameName) + ' max: ' + str(oChnX.Properties("maximum").value))
#Create date/time channel
oChnDateTime = oGrp.Channels.AddChannel(oChnX)
oChnDateTime.Name = "DateTime"
#Define the datetime offset.
import datetime
current_time = datetime.datetime.now()
#oUsiLocal = dd.CreateTime(current_time.year, current_time.month, current_time.day, current_time.hour, current_time.minute, current_time.second, current_time.microsecond)
oUsiLocal = dd.CreateTime(current_time.year, current_time.month, current_time.day, current_time.hour, current_time.minute, current_time.second)
#Convert the numeric channel oChnDateTime to a channel data type of time (date/time).
dd.ChnNumericToTime(oChnDateTime, oUsiLocal.GetUTC.SecondsFrom0000 + oUsiLocal.Fraction, False)
oChnDateTime.Properties.Add('description', 'Derived from channel "time"')
#Create a numeric channel
oChnY = oGrp.Channels.Add("Numeric",dd.DataTypeFloat64)
#ChnGenVal(ChnArg1, ChnRow, ValNo, ChnBegin, ChnStep
dd.ChnGenVal(oChnY, 1, 100, 0.0, 1.0/33.0)
oChnY.XRelation = oChnX
oChnY.UnitSymbol = 'psi'
#print(oChnY.GetReference(dd.eRefTypeNameName) + ' max: ' + str(oChnY.Properties("maximum").value))
#Update the 2nd value/row in oChnY to be 0.30
oChnY.SetValues(0.30, 2)
#Create a waveform channel
oChnWf = oGrp.Channels.AddChannel(oChnY)
oChnWf.Name = "Waveform"
dd.ChnToWfChn(oChnDateTime, oChnWf, False, "WfXAbsolute")
#Create a numeric channel from the waveform channel oChnWf
oChnY = oGrp.Channels.AddChannel(oChnWf)
oChnY.Name = "NumericFromWf"
oElementList = dd.WfChnToChn(oChnY, True, "WfXAbsolute")
oElementList.Item(1).Name = "DateTimeNumericFromWf"
#Remove all of the channels just created
"""
for c in range(oGrp.Channels.Count, 0, -1):
print('\tRemoving channel ' + oGrp.Channels.Item(c).Name)
oChn = oGrp.Channels.Item(c)
#dd.Data.Remove(dd.Data.GetChannels(oChn.GetReference(dd.eReferenceNameName))
ChnRemove(oChn)
#Remove the channel group
dd.Data.Root.ChannelGroups.Remove(oGrp.Name)
"""
dd.Portal.Refresh()
bTestDIAdemScriptEnv()
Do you need help customizing DIAdem using Python for your specific test measurement data management needs? Click on the button below to book a free 1 hour phone / web share consultation.
Sitemap | Copyright © 2020 - 2024 Mechatronic Solutions LLC
Web site by www.MechatronicSolutionsLLC.com | | 287.3550 ms