--starttime = os.clock() local function GetTimeStamp() return os.date("%d/%m/%Y %H:%M:%S", ScenEdit_CurrentTime()) end --Data structure for the log local data ={ timestamp=a, contact_guid=a, contact_name=a, estimated_latitude=a, estimated_longitude=a, solid=a, time_detected=a, sensor_name=a, sensor_type=a, sensor_role=a, --detected_by=a } local function GetSolid(solid) if solid then return 1 else return 0 end end local function ELINT_Detection(t_table) --Checks if any of the last detections is by a ELINT unit local function GetElint(guid) local ELINT = {'99RS00','961AACS00','U11VUP00','38RS00' } for _,EL in ipairs(ELINT) do if string.find(guid,EL) ~= nil then return true end end return false end for k,v in ipairs(t_table) do --TRUE If the contact is less than a minute an is made by a ELINT UNIT if v.age <= 60 and GetElint(v.detector_guid) then return true else return false end end end local US_SIDE = bL3.Sides.US_SIDE local contacts = VP_GetSide({side=US_SIDE}).contacts for _,g in ipairs(contacts) do --print(g) local contact = ScenEdit_GetContact({side=US_SIDE, guid=g.guid}) local c_guid = contact.guid local unit = SE_GetUnit({guid=contact.actualunitid}) if unit.side == 'Civilian' then goto continue end local emissions = contact.emissions local lastD = contact.lastDetections if emissions~= nil and lastD ~= nil and math.random()<0.99 then if ELINT_Detection(lastD) then for k,em in ipairs(emissions) do local age = em.age if em.age < 3600 then local d = data d.timestamp = GetTimeStamp() d.contact_guid = contact.guid d.contact_name = contact.name d.estimated_latitude = contact.latitude d.estimated_longitude = contact.longitude d.solid = GetSolid(em.solid) d.sensor_name = em.sensor_name d.sensor_type = em.sensor_type d.sensor_role = em.sensor_role d.time_detected = em.age print('[ELINT LOG];'..d.timestamp..";"..d.contact_guid..";"..d.contact_name..";"..d.estimated_latitude..";"..d.estimated_longitude..";"..d.solid..";"..d.sensor_name..";"..d.sensor_type..";"..d.sensor_role..";"..d.time_detected) end end end end ::continue:: end --local timetaken = (os.clock() - starttime) * 1000 --print(string.format('timetaken (ms): %.8f',timetaken));