R/checkwindr.R

#
#   extraTechInds: extra Technical Indicators of TTR and quantmod
#
#   Copyright (C) 2016  Chen Chaozong
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#' Check WindR stuats
#'
#' @aliases checkwindr

checkwindr <- function(){
  if(exists("w.isconnected")){
    if(w.isconnected()) {
      message("use w.menu() to get more help")
      return(0)
    }
  } else {
    load <- try(library("WindR",quietly = TRUE),silent = TRUE)
    if(class(load)=="try-error") {
      message("Can not library WindR!")
      return("load windr error")
    }
  }
  start <- w.start(showmenu = F)
  if(start$ErrorCode!=0){
    message(paste("Can not start WindR, error :",start$ErrorMsg))
    return("start windr error")
  }
  message(start$ErrorMsg)
  return(0)
}
Chen-Chaozong/getwinddata documentation built on May 6, 2019, 10:10 a.m.