02-08-2016 10:07 AM
Hi Estefania,
The error you got was due to the fact that some channels were analyze which had no 0..1 or 1..0 transitions in them. I ammended to code to just ignore such channels. I also changed the code to only analyze channels based on whether the channel name contained a particular ChnNameMatch string in it (the string comparison is carried out in lower case always). I also edited the code to flag channels that were filtered with a "Filtered" text in their "Description" property, so you can easily see if a channel has been filtered by the script. You will need to change line 2 below to the "savings" string or any other you want to analyze-- there were no such channels in the 2 data files you sent me.
MinDuration = 100 '60*60 ' seconds ChanNameMatch = "boiler 1 m2g" WndShow "VIEW" Set Group = Data.Root.ActiveChannelGroup Set TimeChannel = Group.Channels(1) FOR Each BoolChannel In Group.Channels IF InStr(LCase(BoolChannel.Name), ChanNameMatch) > 0 THEN ChnComment(BoolChannel) = "Filtered" EventList = ChnEventDetectionWindow(TimeChannel, BoolChannel, 0.5, 1.5) nMax = ChnEventCount(EventList) FOR n = 1 TO nMax P1 = EventList(n-1, 0) P2 = EventList(n-1, 1) Duration = TimeChannel.dValues(P2) - TimeChannel.dValues(P1) IF Duration < MinDuration THEN Call BoolChannel.SetValues(0.0, P1, P2-P1+1, 0) END IF NEXT ' n EventList = ChnEventDetectionWindow(TimeChannel, BoolChannel, -0.5, 0.5) nMax = ChnEventCount(EventList) FOR n = 1 TO nMax P1 = EventList(n-1, 0) P2 = EventList(n-1, 1) Duration = TimeChannel.dValues(P2) - TimeChannel.dValues(P1) IF Duration < MinDuration THEN Call BoolChannel.SetValues(1.0, P1, P2-P1+1, 0) END IF NEXT ' n END IF ' BoolChannel NEXT ' BoolChannel
I also changed the DataPlugin to use the text to the left of the pipe character ("|") in the channel name as the group name. This made it easier for me to use the same VIEW layout to analyze multiple CSV files from you. Please detach and double-click on the attached newer version of the emendezcampa_CSV data file, click on the "Yes" button to overwrite the previous version, then use this DataPlugin whenever you load these data files.
Brad
02-09-2016 07:58 AM
Many thanks Brad. Everything works now.
Regards
Estefania