-- -- adsl log processor - plots the ADSL SHOW CHANNEL output of Solwise EL715 ADSL modem. -- -- Description: This script plots the ADSL SHOW CHANNEL output. -- -- To run: I use lua5.1exe and type dofile("adslGD.lua") -- -- See: www.lua.org and http://lua-gd.luaforge.net/ for lua downloads -- -- unpack gd and copy lua5.1.exe and lua5.1.dll into lua-gd-2.0.33r2 -- -- dofile("adslGD.lua") -- Copyright: Doug Rice 2007 -- lua-GD: http://lua-gd.luaforge.net/manual.html#license.luagd -- http://www.lua.org/license.html -- -- log files are read from .\adslLogs -- plots are put into .\png directory -- -- -------------------------------------------------- -- Sec 0.0 includes -- -------------------------------------------------- require "gd" -- -------------------------------------------------- -- Sec 1.0 Variables -- -------------------------------------------------- -- data files to be parsed dataFilesA = { --[==[ "adsl_support.log", "adsl_support2.log", "adslLog060910.txt", "adslLogCh.txt", "adslLog.txt", "adslLgCh.txt", "adsl_070909.log", "adsl_f1_c1.log", "adsl_f1_c2.log", "adsl_f1_c3.log", "adsl_f2_c1.log", "adsl_f3_c1.log", "adsl_f3_c2.log", "adsl_f3_c3.log", "adsl_f3_c4.log", "adsl_f3_c5.log", "adsl_f3_c6.log", "adsl_f3_c7.log", "adsl_f3_c8.log", "adsl_f3_c9.log", "adsl_f3_c10.log", "adsl_f3_c11.log", "adsl_f3_c12.log", "adsl_f4_c1.log", "adsl_f4_c2.log", "adsl_f4_c3.log", "adsl_f4_c4.log", "adsl_f4_c5.log", "adsl_f2f4_c1.log", "adsl_f2f4_c2.log", "adsl_f2f4_c3.log", "adsl_f2f4_c4.log", "adsl_f2f4_c5.log", "adsl_f2f4_c6.log", "adsl_f2f4_c7.log", "adsl_f2f4_c8.log", "adsl_f2f4_c9.log", -- A micro filter with CE mark sold to me by Elmers "adsl_f5_c1.log", "adsl_f5_c2.log", "adsl_f5_c3.log", "adsl_f5_c4.log", "adsl_f5_c5.log", "adsl_f5_c6.log", "adsl_f5_c7.log", "adsl_f5_c8.log", "adsl080110.log", "adsl080111.log", "adsl080115.log", "adsl080110.log", "adsl080111.log", "adsl080115.log", "adsl080130.log", "adsl080208.log", "adsl080419.log", "adsl080429.log", "adsl080504.log", "adsl080514.log", "adsl080517.log", ]==] "adsl.log" } dataFile = "adsl_f2f4_c1.log" gphA = {} timeStamp = "" downStr = "" -- -------------------------------------------------- -- Sec 1.1 Parse data to find the limits -- -------------------------------------------------- function firstPass( dataFile ) gphA["fname"]=dataFile gphA["dn"]={} gphA["up"]={} fname = dataFile:match( "(%w*).") print( fname ) fp = io.open( ".\\adslLogs\\" .. dataFile, "r+") if ( fp ) then else print("File Not Found: ".. dataFile .. "\n" ) return end instCnt = 0 trigger = false for line in fp:lines() do if line:match( "UTC" ) then timeStamp = line end if wantNextLine then timeStamp = line wantNextLine = false end if line:match( "===ADSL===" ) then wantNextLine = true end --Data Path : Interleaved -- Downstream Bit Rate : 2752 Kbps -- Upstream Bit Rate : 448 Kbps if line:match( "Downstream Bit Rate :" ) then downStr = " Down/Up: " ..line:match( "Downstream Bit Rate : (%d*)" ) end if line:match( "Upstream Bit Rate :" ) then downStr = downStr .. "/" ..line:match( "Upstream Bit Rate : (%d*)" ) end if line:match( "Upstream Bit Load :" ) then -- print( "Upstream Bit Load :" ) dir = "up" trigger = true end if line:match( "Downstream Bit Load :" ) then -- print( "Downstream Bit Load :" ) dir = "dn" instCnt = instCnt+1 end if line:match( "-->" ) then -- print( "Upstream Bit Load :" ) dir = "up" if ( trigger == true ) then plotPass( dataFile , instCnt ) downStr = "" timeStamp = "" trigger = false end end -- print( line ) -- parse lines like -- ch[ 64] = 0 ch[ 65] = 9 ch[ 66] = 10 ch[ 67] = 10 -- i1,l1 = line:match("^ch%[%s*(%d*)%] =%s*(%d*)" ) -- i1,l1,i2,l2,i3,l3,i4,l4 = line:match( "^ch%[%s*(%d*)%] =%s*(%d*)ch%[%s*(%d*)%] =%s*(%d*)ch%[%s*(%d*)%] =%s*(%d*)ch%[%s*(%d*)%] =%s*(%d*)" ) -- print( line:match("(ch%[%s*%d*%] =%s*%d*)") ) -- i1,l1 = line:match("ch%[%s*(%d*)%] =%s*(%d*)" ) -- if i1 then print( i1 , l1 ) end for i1,l1 in line:gmatch( "ch%[%s*(%d*)%] =%s*(%d*)" ) do -- print( i1, l1 ) gphA[ dir ][i1*1] = l1*1 -- print( i1, l1, gphA[ dir ][i1*1] ) end end fp:close() fname = dataFile:match( "([^.]*)") print( dataFile .. " \n" ) end function plotPass( dataFile,inst ) fname = dataFile:match( "([^.]*)") xOff = 20 xScale = 3 yOff = 112 yOff2 = 15 yScale = 5 yMax = 10 im = gd.createTrueColor( (256+32) * xScale+4+xOff*2, yMax*yScale*2+yOff2*2) bg = im:colorAllocateAlpha(250, 250, 250 , 0) im:filledRectangle(0,0,(256+32) * xScale+4+xOff*2, yMax*yScale*2+yOff2*2, bg ) bg = im:colorAllocateAlpha(127, 127, 127 , 0) labelClr = im:colorAllocateAlpha(32, 32, 0 , 0) -- im:filledRectangle( 1,1,260,150, bg ) -- first allocated color defines the background. white = im:colorAllocate(255, 255, 255) black = im:colorAllocate(0, 0, 0) red = im:colorAllocate(255, 0, 0) yellow = im:colorAllocate(255, 255, 0) green = im:colorAllocate(0xb3, 0xb3, 0) cyan = im:colorAllocate(0x66, 0x66, 0x00) blue = im:colorAllocate(0, 0, 255) mag = im:colorAllocate(255, 0, 255) gray = im:colorAllocateAlpha(255, 255, 0xCC, 64) gray2 = im:colorAllocateAlpha(0, 0, 0, 100) coloursA = { black,red,yellow,green, cyan,blue,mag,white,black,red,yellow,green, cyan,blue,mag,white } -- im:string(gd.FONT_LARGE, 10, 5, "dataFile: ".. fname .."_" .. inst .. ".png" .. " @ " .. timeStamp .. downStr , labelClr) -- --------------- -- plot grid -- --------------- print( "a_"..fname.."_" .. inst .. ".png" ) -- draw axis for down stream channels im:filledRectangle( 0*xScale+xOff , 0+yOff-(16*yScale) , 257*xScale+1+xOff , 0+yOff-(-1*yScale), gray ) im:rectangle( 0*xScale+xOff , 0+yOff-(16*yScale) , 257*xScale+1+xOff , 0+yOff-(-1*yScale), black ) for x = 0 , 256 , 16 do im:rectangle( x*xScale+xOff , 0+yOff+2 , x*xScale+1+xOff , 0+yOff+4, black ) end -- --------------- -- plot DownStream Bit Loads -- --------------- for x = 0 , 255 , 1 do yMax = gphA[ "dn" ][x]*yScale colour = green im:filledRectangle( x*xScale+xOff , 0+yOff-yMax , x*xScale+1+xOff , 0+yOff, colour ) end -- draw axis for up channels im:filledRectangle( 258*xScale+xOff , 0+yOff-(16*yScale) , (258+32)*xScale+1+xOff , 0+yOff-(-1*yScale), gray ) im:rectangle( 258*xScale+xOff , 0+yOff-(16*yScale) , (258+32)*xScale+1+xOff , 0+yOff-(-1*yScale), black ) for x = 0 , 32 , 16 do im:rectangle( (x+258)*xScale+xOff , 0+yOff+2 , (x+258)*xScale+1+xOff , 0+yOff+4, black ) end -- --------------- -- plot UpStream Bit Loads -- --------------- for x = 0 , 31 , 1 do yMax = gphA[ "up" ][x]*yScale colour = cyan im:filledRectangle( (x+258)*xScale+xOff , 0+yOff-yMax , (x+258)*xScale+1+xOff , 0+yOff, colour ) end -- --------------- -- plot Y Axis -- --------------- for y = 0 , 12 , 4 do im:line( xOff+4 , 0+yOff-y*yScale , xOff+256*xScale , 0+yOff-y*yScale, gray2 ) im:line( 258 * xScale + xOff+4 , 0+yOff-y*yScale , 258 * xScale +xOff+32*xScale , 0+yOff-y*yScale, gray2 ) im:string(gd.FONT_TINY, 0*xScale+1, 0+yOff-y*yScale-2 , " " .. y , labelClr) end im:string(gd.FONT_LARGE, 10, 5, "dataFile: ".. fname .."_" .. inst .. ".png" .. " @ " .. timeStamp .. downStr , labelClr) -- im:string(gd.FONT_TINY, (128 -8 )*xScale+xOff , 0+yOff-(16*yScale)-25 , "Solwise 715 modem ADSL SHOW CHANNEL output ploted Downstream Bit Load" , labelClr) -- im:string(gd.FONT_TINY, (0 +257 +0 )*xScale+xOff , 0+yOff-(16*yScale)-10 , "Upstream Bit Load" , labelClr) im:string(gd.FONT_TINY, xOff +8 , 0+yOff-(16*yScale) -10 , "plots of Solwise 715 modem ADSL SHOW CHANNEL output" , labelClr) im:string(gd.FONT_TINY, (128 -8 )*xScale+xOff , 0+yOff + 7 , "Downstream Bit Load" , labelClr) im:string(gd.FONT_TINY, (0 +257 +3 )*xScale+xOff , 0+yOff + 7 , "Upstream Bit Load" , labelClr) -- im:string(gd.FONT_TINY, (32+257 +0 )*xScale+xOff , 0+yOff+yIncAcc , "Sum BitLoads Dn/Up, DownStream/Upstream, Timestamp" , labelClr) -- --------------- -- create .png file -- --------------- im:png("./png/"..fname.."_" .. inst .. ".png") end -- --------------- -- Main Program -- --------------- cnt=1 while dataFilesA[cnt] do -- --------------- -- Work Through array of file names -- --------------- dataFile = dataFilesA[cnt] firstPass( dataFile ) cnt = cnt + 1 end