GetTime with S4
Hi folks.
I wonder if it is possible to use gettime on s4, to write a message (TP ...) on the pendant at a certain time?
I can't find that command on the pendant, but it might be written offline?
Kindly.
Kindly.
0
Comments
-
The older function is CTime:
VAR string time;
time := CTime();
Lee Justice0 -
Thank you, maybe you can find the solution for me in this example?
weekday := GetTime(\WDay);
hour := GetTime(\Hour);
IF weekday < 6 AND hour >6 AND hour < 16 THEN
TPWrite "Day shift";ELSE
TPWrite "Evening shift";ENDIF0 -
So the returned value of CTime is string. You will dissect the string with StrPart function and then use StrToVal function to change to numeric values with which you can make such an evaluation.Lee Justice0
-
You won't get day of the week, but you can also use CDate to fetch the current date.Lee Justice0
-
Thanks, as you understand, I am beginner.
Now I read the manual to understand your answer.
So can you write an exemple that I can later modify at the right time?0 -
VAR string time;
VAR string stHour;
VAR num nHour;
VAR bool bOk;
time := CTime();
stHour:=StrPart(time,1.2);
bOk:=StrToVal(stHour,nHour);
Then you can use the value written into nHour by the StrToVal function to determine "Day" or "Evening" shift.Lee Justice0 -
Thanks again.
Will copy this and test it tomorrow when I come back to the work.0 -
Maybe this will help you. Can modify as you would like. I don't know if it will work on S4 though. This is done for IRC5;
Just add PROC "Details" wherever you want the TP to display this details.MODULE Print_TP LOCAL CONST string Months_Name{12}:=["January","February","March","April","May","June","July","August","September","October","November","December"]; LOCAL CONST string Months_Number{12}:=["01","02","03","04","05","06","07","08","09","10","11","12"]; LOCAL PERS string sDayWeek:=""; LOCAL PERS string sMonths:=""; LOCAL PERS string sYear:=""; LOCAL PERS string sTime:=""; LOCAL VAR intnum intReadDateToday; LOCAL PERS bool bDetailsPrinted:=TRUE; LOCAL PERS num nTimeHour:=12; LOCAL PERS num nTimeMinute:=43; LOCAL PERS num nTimeSecond:=59; LOCAL PERS string sWeekday:=""; PROC Details() WHILE bDetailsPrinted=FALSE DO nTimeHour:=GetTime(\Hour); nTimeMinute:=GetTime(\Min); nTimeSecond:=GetTime(\Sec); IF nTimeHour>06 OR nTimeHour<17 AND nTimeMinute=59 OR nTimeMinute<59 AND nTimeSecond=00 THEN IF bDetailsPrinted=FALSE THEN TPErase; TPWrite Weekday(sDayWeek); TPWrite Month(sMonths); TPWrite Year(sYear); TPWrite Time(sTime); TPWrite "Shift: Dayshift"; bDetailsPrinted:=TRUE; ENDIF ELSEIF nTimeHour>18 OR nTimeHour<05 AND nTimeMinute=59 OR nTimeMinute<59 AND nTimeSecond=00 THEN IF bDetailsPrinted=FALSE THEN TPErase; TPWrite Weekday(sDayWeek); TPWrite Month(sMonths); TPWrite Year(sYear); TPWrite Time(sTime); TPWrite "Shift: Nightshift"; bDetailsPrinted:=TRUE; ENDIF ENDIF ENDWHILE ENDPROC LOCAL FUNC string Weekday(String DayWeek) VAR num nWeekday; VAR string sDayWeek; nWeekday:=GetTime(\WDay); IF nWeekday=1 sDayWeek:=sWeekDays{1}; IF nWeekday=2 sDayWeek:=sWeekDays{2}; IF nWeekday=3 sDayWeek:=sWeekDays{3}; IF nWeekday=4 sDayWeek:=sWeekDays{4}; IF nWeekday=5 sDayWeek:=sWeekDays{5}; IF nWeekday=6 sDayWeek:=sWeekDays{6}; IF nWeekday=7 sDayWeek:=sWeekDays{7}; RETURN "Weekday: "+sDayWeek; ENDFUNC LOCAL FUNC string Month(String Months) VAR string sMonths; VAR string sDate; VAR num nMonths; sDate:=CDate(); Months:=StrPart(sDate,6,2); IF Months=Months_Number{1} Months:=Months_Name{1}; IF Months=Months_Number{2} Months:=Months_Name{2}; IF Months=Months_Number{3} Months:=Months_Name{3}; IF Months=Months_Number{4} Months:=Months_Name{4}; IF Months=Months_Number{5} Months:=Months_Name{5}; IF Months=Months_Number{6} Months:=Months_Name{6}; IF Months=Months_Number{7} Months:=Months_Name{7}; IF Months=Months_Number{8} Months:=Months_Name{8}; IF Months=Months_Number{9} Months:=Months_Name{9}; IF Months=Months_Number{10} Months:=Months_Name{10}; IF Months=Months_Number{11} Months:=Months_Name{11}; IF Months=Months_Number{12} Months:=Months_Name{12}; RETURN "Month: "+Months; ENDFUNC LOCAL FUNC string Year(String Year) VAR string sYear; VAR string sDate; VAR num nMonths; sDate:=CDate(); sYear:=StrPart(sDate,1,4); RETURN "Year: "+sYear; ENDFUNC LOCAL FUNC string Time(String Time) VAR string sTime; sTime:=CTime(); RETURN "Time: "+sTime; ENDFUNC ENDMODULE
1 -
When I loaded the 7 lines that # lemster68 # sent, I got these errors
0 -
When I load only 7 lines from #lemster68#, I get this on screen.
0 -
How about the screen that shows the code? These ones only show that there was an error.Lee Justice0
-
I put it in one paintprogram.
But the stop comes before, in mainprog.
On the line:
LoadProg NORMAL_PROG, stNextProgNormal, stPathProgDir;
0 -
Try entering the code line by line using the pendant.Lee Justice0
-
Now I have come further.
I get into paintprogram and there I get the error message:
Too few arguments in call to routine StrPart.0 -
Hello,A char is missing in lemster68 code. Should be:stHour:=StrPart(time,1,.2);
0 -
Thanks.
After I have loaded hint from DenisFR, I have got error message:
Illegal value of argument for parameter.0 -
The font is abit small for me to read well, but it looks like there may be a typo. A period instead of a comma: stHour:=StrPart(time,1,2);Lee Justice0
-
Thanks.
Now its running with out stopp :-)
But do you have a solution on how to get the value out and use it in an IF instruction?
So the robot for ex:
PaintL P1, 500, z1,t_ref150\Wobj:=wobjcnv1;
PaintL P2, 500, z1,t_ref150\Wobj:=wobjcnv1;
PaintL P3, 500, z1,t_ref150\Wobj:=wobjcnv1;
PaintL P4, 500, z1,t_ref150\Wobj:=wobjcnv1;
PaintL P5, 500, z1,t_ref150\Wobj:=wobjcnv1;
The robot go from P1, P2 and P5 all time, and depending on the time of day, the robot should go to P3 in the day and P4 in the evening.
0 -
PaintL P1
PaintL P2
IF nHour < 16 THEN
PaintL P3
ELSE
PaintL P4
ENDIF
PaintL P5Lee Justice0 -
MANY, MANY thanks to you!!!
I'll test that next week.
I want to divide the day into 3 parts, if its possible?
00:00 to 07:00,
7:00 to 15:30,
15:30 to 24:00.0 -
Yes. IF (nHour > 0) AND (nHour < 7) THEN
Do something
ELSEIF (nHour > 7) AND (nHour < 15) THEN
Do something else
ELSEIF more of the same...
Do something else
ENDIF
But for the 30 minutes part you will need to read in the minutes and add that too.Lee Justice0 -
YOU have helped me so, so much.
I have no robot to test now but, is this right?
VAR string time;
VAR string stHour;
VAR num nHour;
VAR num nMinute;
VAR bool bOk;
time := CTime();
stHour:=StrPart(time,1,2);
stMinute:=StrPart(time,1,2);
bOk:=StrToVal(stHour,nHour);
bOk:=StrToVal(stHour,nMinute);
IF (nHour > 0) AND (nHour < 7) THEN
Do something
ELSEIF (nHour > 7) AND (nHour >15,nMinute<30) THEN
Do something else
ELSEIF more of the same...
Do something else
ENDIF
0 -
stMinute:=StrPart(time,1,2);
Change to:
stMinute:=StrPart(time,4,2);
bOk:=StrToVal(stHour,nMinute);
Change to:
bOk:=StrToVal(stMinute,nMinute);
ELSEIF (nHour > 7) AND (nHour >15,nMinute<30) THEN
Change to:
ELSEIF (nHour > 7) AND (nHour >15) AND (nMinute<30) THEN
Lee Justice0 -
I go on vacation next week, so even you get free from me :-)
But I will test this, week 9 and will tell you how it is going.0 -
Hi again.
This line may not be OK.ELSEIF (nHour > 7) AND (nHour >15) AND (nMinute<30) THEN
No error message, but nothing happens.
When I only white with whole hours it works.ELSEIF (nHour > 7) AND (nHour >15) THEN0 -
I see now that this logic is a bit funny:
ELSEIF (nHour > 7) AND (nHour >15) AND (nMinute<30) THEN
If nHour > 15 then of course it is greater than 7. Might just simplify to:
IF (nHour = 15) AND (nMinute < 30) THENLee Justice0 -
0
-
Hi.
Now it works just as I had imagined.
(except weekdays).
But I am more than satisfied.
Thank you so much again !!!
0 -
You are welcome.Lee Justice0
-
Hi. Thanks for all help I got from you in "GetTime with S4". Now it works and the robot doesn't stop (good), so I've tested many different times, etc., but can't find the solution The times I want is: 0:24 -> 6:48 TPWrite "1";
6:48 -> 15:42 TPWrite "2";
15:42 -> 0:24 TPWrite "3";
Know that there are several errors, but can not find the right one. Please, can you find a solution for me, below?IF (nHour >= 0) AND (nMinute > 24) AND (nHour = 6) AND (nMinute < 48) THEN TPWrite "1"; ELSEIF (nHour >= 6) AND (nMinute >= 48) AND (nHour < 16) AND (nMinute < 42) THEN TPWrite "2"; ELSE TPWrite "3"; ENDIF
Kindly.0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings