Post by honky on Jul 15, 2024 12:39:11 GMT
Or a battery of 200 A*H 12 Volts, and a "consumer" of 40 Watts 12 Volts.
I would like to display in real time (every second), the remaining consumption time (hour an minuts).
I (ampères) = p (watts) / u (volts),
I have a code but it's long (many consumers).
I would like to display in real time (every second), the remaining consumption time (hour an minuts).
I (ampères) = p (watts) / u (volts),
I have a code but it's long (many consumers).
Thank you for.
mois$ = "Jan Fév Mar Avr Mai Jun Jui Aou Sep Oct Nov Déc"
today$ = date$("mm/dd/yyyy")
j = date$(today$)
jsem$ = word$("Mar Mer Jeu x Ven Sam x Dim Lun",int((j/7-int(j/7))*10)+1)
date$ = jsem$+" "+mid$(today$,4,2)+" "+word$(mois$, val(today$))'+" "+left$(time$(),5)
NOMAINWIN
mapw=400: maph= 400
WindowWidth=mapw+15: WindowHeight=maph+40
UpperLeftX = 10: UpperLeftY = 10
TEXTBOX #w.cap, 110, 20, 80, 25
TEXTBOX #w.tens, 285, 20, 80, 25
TEXTBOX #w.ppc, 110, 50, 80, 25
TEXTBOX #w.cons, 285, 50, 80, 25
TEXTBOX #w.pv1, 110, 80, 80, 25
TEXTBOX #w.pv2, 110, 110, 80, 25
TEXTBOX #w.pv3, 110, 140, 80, 25
TEXTBOX #w.pv4, 110, 170, 80, 25
TEXTBOX #w.pv5, 110, 200, 80, 25
TEXTBOX #w.pv6, 110, 230, 80, 25
BUTTON #w.v1, "V 1", [v1], UL, 210, 80, 80, 25
BUTTON #w.v2, "V 2", [v2], UL, 210, 110, 80, 25
BUTTON #w.v3, "V 3", [v3], UL, 210, 140, 80, 25
BUTTON #w.v4, "V 4", [v4], UL, 210, 170, 80, 25
BUTTON #w.v5, "V 5", [v5], UL, 210, 200, 80, 25
BUTTON #w.v6, "V 6", [v6], UL, 210, 230, 80, 25
TEXTBOX #w.res, 110, 270, 200, 40
BUTTON #w.go, "Start", [go], UL, 50, 350, 70, 25
BUTTON #w.stop, "Stop", [stop], UL, 150, 350, 70, 25
GRAPHICBOX #w.g, 5, 5, mapw, maph
OPEN "Calculateur Temps ";date$ FOR window_nf AS #w
#w, "TRAPCLOSE [closeHelp]"
#w.g, "when rightButtonDown [coord]"
#w.g, "down;fill darkpink;color white;backcolor darkpink"
#w, "font courrier 12 bold": #w.res, "!font courrier 16 bold"
#w.g, "place 10 30": #w.g, "\Capacité A*H": #w.g, "place 200 30": #w.g, "\Tension V"
#w.g, "place 10 60": #w.g, "\P pc W": #w.g, "place 200 60": #w.g, "\Conso A"
#w.g, "place 10 90": #w.g, "\P V1 W"
#w.g, "place 10 120": #w.g, "\P V2 W"
#w.g, "place 10 150": #w.g, "\P V3 W"
#w.g, "place 10 180": #w.g, "\P V4 W"
#w.g, "place 10 210": #w.g, "\P V5 W"
#w.g, "place 10 240": #w.g, "\P V6 W"
#w.g, "place 10 280": #w.g, "\Reste"
#w.g, "flush"
cap=400: ppc=20: pv1=50: pv2=100: pv3=150
pv4=200: pv5=250: pv6=300: tens=12
' gosub [opini]
#w.cap, str$(cap): #w.ppc, str$(ppc): #w.pv1, str$(pv1): #w.pv2, str$(pv2): #w.pv3, str$(pv3)
#w.pv4, str$(pv4): #w.pv5, str$(pv5): #w.pv6, str$(pv6): #w.tens, str$(tens)
#w.v1, "!disable": #w.v2, "!disable": #w.v3, "!disable": #w.v4, "!disable": #w.v5, "!disable": #w.v6, "!disable"
wait
[go]
#w.v1, "!enable": #w.v2, "!enable": #w.v3, "!enable": #w.v4, "!enable": #w.v5, "!enable": #w.v6, "!enable"
tdep=time$("seconds")
icons=ppc/tens
goto [calc]
wait
[calc]
p=cap*tens
trest=p/ppc
[ret]
t=(tactu-tdep)/3600
cons=icons*t
tactu=time$("seconds")
trest=p/(pa+ppc)
mimin=trest-int(trest)
mimin=int(mimin * 100)/100: mimin=mimin*100
min=mimin/100*60
#w.res, str$(int(trest));" h ";str$(int(min));" mn"
icons=(pa+ppc)/tens
#w.cons, str$(icons)
gosub [pause]
if sto=1 then wait
goto [ret]
wait
[v1] pa=pv1: goto [calc]
[v2] pa=pv2: goto [calc]
[v3] pa=pv3: goto [calc]
[v4] pa=pv4: goto [calc]
[v5] pa=pv5: goto [calc]
[v6] pa=pv6: goto [calc]
wait
[savini]
#w.cap, "!contents? cap$": #w.ppc, "!contents? ppc$": #w.pv1, "!contents? pv1$"
#w.pv2, "!contents? pv2$": #w.pv3, "!contents? pv3$": #w.pv4, "!contents? pv4$"
#w.pv5, "!contents? pv5$": #w.pv6, "!contents? pv6$": #w.tens, "!contents? tens$"
open "ini.txt" for output as #f
print #f, cap$
print #f, ppc$
print #f, pv1$
print #f, pv2$
print #f, pv3$
print #f, pv4$
print #f, pv5$
print #f, pv6$
print #f, tens$
close #f
return
[opini]
open "ini.txt" for input as #g 'Ouverture fichier en lecture
while eof(#g)=0
line input #g, cap$: cap=val(cap$)
line input #g, ppc$: ppc=val(ppc$)
line input #g, pv1$: pv1=val(pv1$)
line input #g, pv2$: pv2=val(pv2$)
line input #g, pv3$: pv3=val(pv3$)
line input #g, pv4$: pv4=val(pv4$)
line input #g, pv5$: pv5=val(pv5$)
line input #g, pv6$: pv6=val(pv6$)
line input #g, tens$: tens=val(tens$)
wend
close #g
return
[stop]
sto=1
wait
[coord]
mx=MouseX: my=MouseY
#w.g, "place ";mx;" ";my: #w.g, "\"; str$(mx);" ";str$(my)
wait
[pause]
timer 0, [temps]
wait
[temps]
timer 0
return
[closeHelp]
' gosub [savini]
CLOSE #w
END