#############################
#imports
#############################

useDynLib("pems.utils", .registration=TRUE)


## import/depends

import(lattice)
import(loa)

#NEED to work out how to compile
#with imports
#currently library loaded
#so user/examples accessible
#seems to need these imported as well as depends

## imports

import(grid)
import(RColorBrewer)
import(latticeExtra)
import(dplyr)

## no longer importing all package

#import(baseline) #just importing used functions  
                  #because of plot conflict with graphics...
#import(utils) #just importing head and tail methods
#import(ggplot2) #just importing fortify

## replaced depends/imports...

#import(plyr) #replacing with dplyr

## requested by CRAN

importFrom("grDevices", "colorRampPalette", "gray")
importFrom("graphics", "abline", "arrows", "plot")
importFrom("methods", "is")
importFrom("stats", "aggregate", "as.formula", "ccf", "model.frame",
           "na.omit", "na.pass", "complete.cases", "approx", "lm", 
           "predict")
importFrom(utils, read.table, read.csv, read.delim, write.table, 
           head, tail, capture.output, install.packages, 
           installed.packages)
importFrom(baseline, baseline, getBaseline, getCorrected)

#importFrom(lazyeval, lazy, lazy_eval) #replaced this with rlang, eval_tidy, etc...
importFrom(rlang, eval_tidy, quo_is_null, get_expr, exprs)

#I don't think I need to importFrom round because 
#  it is primative and in base...



##########################
#pems.utils generics
##########################

##imported methods

#in base/don't need to importFrom?
#as.data.frame, print, units

#primatives/don't need to importFrom
#dim, names, 

#already importFrom elsewhere
#plot from graphics (above)
#head, tail in utils (above)

##generic.pems handlers

S3method(as.data.frame, pems)
S3method(dim, pems)
S3method(print, pems)
S3method(names, pems)
S3method("names<-", pems)
S3method("$", pems)
S3method("$<-", pems)
S3method("[", pems)
S3method("[<-", pems)
S3method(units, pems)
S3method("units<-", pems)
S3method(head, pems)
S3method(tail, pems)
S3method("[[", pems)
S3method("[[<-", pems)
S3method(plot, pems)
S3method(summary, pems)
S3method(with, pems)
S3method(subset, pems)
S3method(na.omit, pems)

#don't need these?
# nrow.pems -dim does it
# ncol.pems -dim does it 


##generic.pems.element handlers

S3method(as.data.frame, pems.element)
S3method(as.pems, pems.element)
S3method(print, pems.element)
S3method("[", pems.element)
S3method("[<-", pems.element)
S3method(plot, pems.element)
S3method(units, pems.element)
S3method("units<-", pems.element)
S3method(summary, pems.element)
S3method(round, pems.element)




##exports

export(as.data.frame)
export(dim)
export(print)
export(names)
export("names<-")
export("[")
export("[<-")
export("$")
export("$<-")
export(units)
export("units<-")
export(head)
export(tail)
export("[[")
export("[[<-")
export(plot)
export(summary)
export(with)
export(subset)
export(left_join)
export(na.omit)



##front.of.house

#make.pems
export(is.pems)
export(pems)
export(pems.element)
export(isPEMS)
export(rebuildPEMS) 
export(makePEMS)
export(makePEMSElement)
export(as.pems)
S3method(as.pems, default)
S3method(as.pems, data.frame)

#import.pems
export(import2PEMS) 
export(importTAB2PEMS) 
export(importCSV2PEMS) 
export(importOBS2PEMS) 
export(importOB12PEMS) 
export(importParSYNC2PEMS)
export(importSEMTECH2PEMS)
export(importCAGE2PEMS)
export(importRoyalTek2PEMS)
export(importKML2PEMS) 

#structure
export(getPEMSElement)
export(getPEMSData)
export(getPEMSConstants)


export(pemsData)
export(pemsConstants)
export(pemsHistory)

#export(pemsin)   #gone 2018/06 0.2.25.17
#export(pemsin2)  #gone 2018/06 0.2.25.17

#merge.pems
export(align)
export(cAlign)
export(findLinearOffset)
export(tAlign)
export(stackPEMS)
#export(bindPEMS)  #gone ~2017/12 0.2.18.01

#testing
export(C_ylagxCOR) 

#export
export(exportPEMSData)
export(exportPEMS2CSV)

###############################
#tidyverse
###############################

#####################
#rlang

#might want to just import all of package?
#import(rlang)
importFrom(rlang, caller_env, have_name, exprs_auto_name)

######################
#dplyr

#not sure why I need to do this
#but it make the methods work without

importFrom(dplyr, select)
export(select)
S3method(select, pems)
S3method(select_, pems)

importFrom(dplyr, rename)
export(rename)
S3method(rename, pems)
S3method(rename_, pems)

importFrom(dplyr, filter)
export(filter)
S3method(filter, pems)
S3method(filter_, pems)

importFrom(dplyr, arrange)
export(arrange)
S3method(arrange, pems)
S3method(arrange_, pems)

importFrom(dplyr, slice)
export(slice)
S3method(slice, pems)
S3method(slice_, pems)

importFrom(dplyr, mutate)
export(mutate)
S3method(mutate, pems)
S3method(mutate_, pems)

importFrom(dplyr, summarise)
export(summarise)
S3method(summarise, pems)
S3method(summarise_, pems)

importFrom(dplyr, pull)
export(pull)
S3method(pull, pems)
#no pull_

importFrom(dplyr, group_by)
export(group_by)
S3method(group_by, pems)
S3method(group_by_, pems)

importFrom(dplyr, ungroup)
export(ungroup)
S3method(ungroup, pems)

importFrom(dplyr, groups)
export(groups)
S3method(groups, pems)

importFrom(dplyr, group_size)
export(group_size)
S3method(group_size, pems)

importFrom(dplyr, n_groups)
export(n_groups)
S3method(n_groups, pems)


importFrom(dplyr, left_join)
S3method(left_join, pems)
export(left_join)

importFrom(dplyr, inner_join)
S3method(inner_join, pems)
export(inner_join)

importFrom(dplyr, right_join)
S3method(right_join, pems)
export(right_join)

importFrom(dplyr, full_join)
S3method(full_join, pems)
export(full_join)

importFrom(dplyr, semi_join)
S3method(semi_join, pems)
export(semi_join)

importFrom(dplyr, anti_join)
S3method(anti_join, pems)
export(anti_join)

#####################
#ggplot2

#need for ggplot2 add-in
importFrom(ggplot2, fortify)
export(fortify)
S3method(fortify, pems)




###########################
#imported whole thing above
#need for head and tail
##importFrom(utils,head)
##importFrom(utils,tail)
###########################

#plots
export(latticePlot)
export(panel.PEMSXYPlot)
export(XYZPlot)
export(pemsPlot)
export(panel.pemsPlot)
export(preprocess.pemsPlot)
export(pemsXYZCondUnitsHandler)
export(WatsonPlot)
export(preprocess.WatsonPlot)
export(panel.WatsonBinPlot)
export(panel.WatsonContourPlot)
export(panel.WatsonSmoothContourPlot)




#calcs
export(calcDistance)
export(calcSpeed)
export(calcAccel)
export(calcAcceleration)
export(calcJerk)
export(calcVSP)
export(calcVSP_JimenezPalacios)
export(calcEm)
export(calcEm_HoribaPitot)

#bins
export(binVSP)
##not exporting/removing...
##export(binVSP.old)
export(binVSP_NCSU.14)
export(binVSP_MOVES.23)

#calc handlers
export(calcChecks)
export(calcPack)

#corrections
export(calcPack2)
export(correctInput)
export(zeroNegatives)
export(correctBaseline)

#cutBy
export(cutBy)
export(cutByRow)

#time.handlers
export(regularize)
export(repairLocalTime)

#unit.handlers
export(getUnits) 
export(setUnits) 
export(convertUnits)
export(addUnitConversion)
export(addUnitAlias)
export(listUnitConversions)

#summaryReports
export(summaryReport) 

#check...functions
##export(checkInput)
## (removed 2018/06/30) 
export(checkOption) 
export(checkPEMS) 
export(checkUnits) 
export(checkOutput)
export(checkIfMissing)


## C code setup 

importFrom(Rcpp, sourceCpp)

