[Stacomir-commits] r342 - in pkg/stacomir: R inst/config inst/examples

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 6 10:23:25 CEST 2017


Author: briand
Date: 2017-04-06 10:23:25 +0200 (Thu, 06 Apr 2017)
New Revision: 342

Modified:
   pkg/stacomir/R/BilanAgedemer.r
   pkg/stacomir/R/BilanMigrationCar.r
   pkg/stacomir/R/RefChoix.r
   pkg/stacomir/R/interface_BilanMigrationPar.r
   pkg/stacomir/inst/config/stacomi_manual_launch.r
   pkg/stacomir/inst/examples/bilanMigrationCar-example.R
Log:


Modified: pkg/stacomir/R/BilanAgedemer.r
===================================================================
--- pkg/stacomir/R/BilanAgedemer.r	2017-04-06 07:30:59 UTC (rev 341)
+++ pkg/stacomir/R/BilanAgedemer.r	2017-04-06 08:23:25 UTC (rev 342)
@@ -182,7 +182,7 @@
 				silent=FALSE){
 			# code for debug using example
 			#horodatedebut="2012-01-01";horodatefin="2013-12-31";dc=c(107,108,101);
-			#taxons='2220';	stades=c('5','11','BEC','BER','IND');par=c('1786','1785','C001');silent=FALSE
+			#taxons=2220;	stades=c('5','11','BEC','BER','IND');par=c('1786','1785','C001');silent=FALSE
 			if (!(is.numeric(limit1hm)|is.integer(limit1hm))) funout(gettext("limit1hm should be numeric or integer",domain="R-stacomiR"),arret=TRUE)
 			if (!(is.numeric(limit2hm)|is.integer(limit2hm))) funout(gettext("limit2hm should be numeric or integer",domain="R-stacomiR"),arret=TRUE)
 			

Modified: pkg/stacomir/R/BilanMigrationCar.r
===================================================================
--- pkg/stacomir/R/BilanMigrationCar.r	2017-04-06 07:30:59 UTC (rev 341)
+++ pkg/stacomir/R/BilanMigrationCar.r	2017-04-06 08:23:25 UTC (rev 342)
@@ -34,19 +34,15 @@
 #' @concept Bilan Object 
 #' @keywords classes
 setClass(Class="BilanMigrationCar",
-		representation=representation(parquan="Refparquan",
-				parqual="Refparqual",
+		representation=representation(
 				echantillon="RefChoix",
-				valeurs_possibles="data.frame",
 				calcdata="list"),
-		prototype=prototype(parquan=new("Refparquan"),
-				parqual=new("Refparqual"),
+		prototype=list(
 				echantillon=new("RefChoix"),
-				valeurs_possibles=data.frame(),
 				calcdata<-list()),
-		contains="BilanMigrationMult")
-#object=bmC
+		contains="Bilan_carlot")
 
+
 setValidity("BilanMigrationCar",function(object)
 		{
 			rep4=length(object at pasDeTemps)==1
@@ -66,6 +62,7 @@
 #' @param car Sample TODO
 #' @param horodatedebut The starting date as a character, formats like \code{\%Y-\%m-\%d} or \code{\%d-\%m-\%Y} can be used as input
 #' @param horodatefin The finishing date of the Bilan, for this class this will be used to calculate the number of daily steps.
+#' @param echantillon Default TRUE, 
 #' @param silent Default FALSE, if TRUE the program should no display messages
 #' @return An object of class \link{BilanAgedemer-class}
 #' The choice_c method fills in the data slot for classes \link{RefDC-class}, \link{RefTaxon-class}, \link{RefStades-class}, \link{Refpar-class} and two slots of \link{RefHorodate-class} and then 
@@ -74,21 +71,18 @@
 #' @export
 setMethod("choice_c",signature=signature("BilanMigrationCar"),definition=function(object,
 				dc,
-				taxons=2220,
-				stades=c('5','11','BEC','BER','IND'),
-				par=c('1786','1785','C001','A124'),
+				taxons,
+				stades,
+				par,
 				horodatedebut,
 				horodatefin,
+				echantillon=TRUE,
 				silent=FALSE){
 			# code for debug using example
-			#horodatedebut="2012-01-01";horodatefin="2013-12-31";dc=c(107,108,101);
-			#taxons='2220';	stades=c('5','11','BEC','BER','IND');par=c('1786','1785','C001');silent=FALSE
+			#horodatedebut="2012-01-01";horodatefin="2013-12-31";dc=c(107,108,101);taxons=2220;	stades=c('5','11','BEC','BER','IND');par=c('1786','1785','C001');silent=FALSE
 			bmC<-object
 			bmC at dc=charge(bmC at dc)
-			# loads and verifies the dc
-			# this will set dc_selectionne slot
 			bmC at dc<-choice_c(object=bmC at dc,dc)
-			# only taxa present in the bilanMigration are used
 			bmC at taxons<-charge_avec_filtre(object=bmC at taxons,bmC at dc@dc_selectionne)			
 			bmC at taxons<-choice_c(bmC at taxons,taxons)
 			bmC at stades<-charge_avec_filtre(object=bmC at stades,bmC at dc@dc_selectionne,bmC at taxons@data$tax_code)	
@@ -105,9 +99,29 @@
 					funoutlabel=gettext("Ending date has been chosen\n",domain="R-stacomiR"),
 					horodate=horodatefin,
 					silent=silent)
-			bmC at limit1hm<-choice_c(bmC at limit1hm,as.character(limit1hm),"limit1hm")
-			bmC at limit2hm<-choice_c(bmC at limit2hm,as.character(limit2hm),"limit2hm")
+			bmC at echantillon<-choice_c(bmC at echantillon,
+
 			validObject(bmC)
+			
+
+			bilan_carlot at dc<-choice_c(object=bilan_carlot at dc,dc)
+			# only taxa present in the bilanMigration are used
+			bilan_carlot at taxons<-charge_avec_filtre(object=bilan_carlot at taxons,bilan_carlot at dc@dc_selectionne)			
+			bilan_carlot at taxons<-choice_c(bilan_carlot at taxons,taxons)
+			bilan_carlot at stades<-charge_avec_filtre(object=bilan_carlot at stades,bilan_carlot at dc@dc_selectionne,bilan_carlot at taxons@data$tax_code)	
+			bilan_carlot at stades<-choice_c(bilan_carlot at stades,stades)
+			bilan_carlot at par<-charge_avec_filtre(object=bilan_carlot at par,bilan_carlot at dc@dc_selectionne,bilan_carlot at taxons@data$tax_code,bilan_carlot at stades@data$std_code)	
+			bilan_carlot at par<-choice_c(bilan_carlot at par,par,silent=silent)
+			bilan_carlot at horodatedebut<-choice_c(object=bilan_carlot at horodatedebut,
+					nomassign="bilan_carlot_date_debut",
+					funoutlabel=gettext("Beginning date has been chosen\n",domain="R-stacomiR"),
+					horodate=horodatedebut, 
+					silent=silent)
+			bilanFonctionnementDC at horodatefin<-choice_c(bilanFonctionnementDC at horodatefin,
+					nomassign="bilan_carlot_date_fin",
+					funoutlabel=gettext("Ending date has been chosen\n",domain="R-stacomiR"),
+					horodate=horodatefin,
+					silent=silent)
 			return(bmC)
 		})
 

Modified: pkg/stacomir/R/RefChoix.r
===================================================================
--- pkg/stacomir/R/RefChoix.r	2017-04-06 07:30:59 UTC (rev 341)
+++ pkg/stacomir/R/RefChoix.r	2017-04-06 08:23:25 UTC (rev 342)
@@ -15,7 +15,6 @@
 
 #' Loading method for Rechoice referential objects
 #' 
-#' 
 #' @family Referential objects
 #' @return An S4 object of class RefChoix
 #' @param object An object of class RefChoix
@@ -62,3 +61,29 @@
 			choice=gradio(items=list_libelle,selected=object at selected,horizontal=TRUE,container=frame_choice,handler=hlist)
 		})
 
+#' Choice_c method for Refchoix referential objects
+#' @param object An object of class \link{RefListe-class}
+#' @note the choice method assigns an object of class refList named refListe in the environment envir_stacomi
+#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @examples  
+#' \dontrun{
+#' object=new("RefListe")
+#' object<-charge(object,vecteur=c("1","2"),label="please choose")
+#' object<-choice_c(object)
+#' }
+setMethod("choice_c",signature=signature("RefChoix"),definition=function(object,selectedvalue) {
+			
+			if (length(selectedvalue)>1) stop("valeurchoisie should be a vector of length 1")
+			if (class (selectedvalue)=="numeric") selectedvalue<-as.character(selectedvalue)
+			# the charge method must be performed before
+			
+			if ( !selectedvalue %in% object at listechoice ) {
+				stop(stringr::str_c("The selected valeur,",selectedvalue," not in the list of possible values :",
+								stringr::str_c(object at listechoice,collapse=",")))
+			} else {
+				object at selectedvalue<-selectedvalue
+			}
+			return(object)
+			
+			
+		})
\ No newline at end of file

Modified: pkg/stacomir/R/interface_BilanMigrationPar.r
===================================================================
--- pkg/stacomir/R/interface_BilanMigrationPar.r	2017-04-06 07:30:59 UTC (rev 341)
+++ pkg/stacomir/R/interface_BilanMigrationPar.r	2017-04-06 08:23:25 UTC (rev 342)
@@ -16,6 +16,7 @@
 	bilanMigrationPar at dc=charge(bilanMigrationPar at dc)
 	bilanMigrationPar at parquan=charge(bilanMigrationPar at parquan)
 	bilanMigrationPar at parqual=charge(bilanMigrationPar at parqual)
+	#TODO transformer la valeur logique de échantillon en un refchoix correct (radiobutton)
 	bilanMigrationPar at echantillon=charge(bilanMigrationPar at echantillon,vecteur=gettext("with","without",domain="R-stacomiR"),
 			label=gettext("Choice of batch type, inclusion of samples ?",domain="R-stacomiR"), 
 					selected=as.integer(1))

Modified: pkg/stacomir/inst/config/stacomi_manual_launch.r
===================================================================
--- pkg/stacomir/inst/config/stacomi_manual_launch.r	2017-04-06 07:30:59 UTC (rev 341)
+++ pkg/stacomir/inst/config/stacomi_manual_launch.r	2017-04-06 08:23:25 UTC (rev 342)
@@ -91,7 +91,7 @@
 source("interface_BilanConditionEnv.r")
 source("interface_BilanMigration.r")
 source("interface_BilanMigrationMultConditionEnv.r")
-source("interface_BilanMigrationPar.r")
+source("interface_BilanMigrationCar.r")
 source("interface_BilanFonctionnementDC.r")
 source("interface_BilanFonctionnementDF.r")
 source("interface_BilanMigrationMult.r")

Modified: pkg/stacomir/inst/examples/bilanMigrationCar-example.R
===================================================================
--- pkg/stacomir/inst/examples/bilanMigrationCar-example.R	2017-04-06 07:30:59 UTC (rev 341)
+++ pkg/stacomir/inst/examples/bilanMigrationCar-example.R	2017-04-06 08:23:25 UTC (rev 342)
@@ -6,7 +6,6 @@
 
 \dontrun{
 	bmC<-new("BilanMigrationCar")
-	bilan_adm<-new("BilanAgedemer")
 	baseODBC<-get("baseODBC",envir=envir_stacomi)
 	baseODBC[c(2,3)]<-rep("logrami",2)
 	assign("baseODBC",baseODBC,envir_stacomi)



More information about the Stacomir-commits mailing list