Meters/Measures Not Auto-Refreshing - rainmeter

I've made a widget that is supposed to tell me what % of my shift is complete, but it's not auto-refreshing so if I want the current value I have to manually refresh the skin. How can I make it auto-refresh?
I've tried setting the Update= manually, adding OnUpdateAction and [!Redraw] and a bunch of other things that I regrettably didn't save since they didn't work so now I can't remember them. (Code below has left out metadata, xy coordinates, and irrelevant variables and values not pertaining to this question such as font settings.)
[Rainmeter]
MiddleMouseDownAction=[!WriteKeyValue Variables OffWorkTime1 #OffWorkTime2#][!WriteKeyValue Variables OffWorkTime2 #OffWorkTime3#][!WriteKeyValue Variables OffWorkTime3 #OffWorkTime4#][!WriteKeyValue Variables OffWorkTime4 #OffWorkTime5#][!WriteKeyValue Variables OffWorkTime5 #OffWorkTime1#][!Refresh]
OnUpdateAction=[!UpdateMeasure MeasurePercElaps][!UpdateMeter MeterPercentDisplay][!WriteKeyValue Variables OffWorkTime1 #OffWorkTime1#][!WriteKeyValue Variables OffWorkTime2 #OffWorkTime2#][!WriteKeyValue Variables OffWorkTime3 #OffWorkTime3#][!WriteKeyValue Variables OffWorkTime4 #OffWorkTime4#][!WriteKeyValue Variables OffWorkTime5 #OffWorkTime5#][!Redraw]
LeftMouseDownAction=[!UpdateMeasure MeasurePercElaps][!UpdateMeter MeterPercentDisplay][!Redraw]
Update=200
[Variables]
OffWorkTime1=870
OffWorkTime2=900
OffWorkTime3=990
OffWorkTime4=1140
OffWorkTime5=1260
HR=[MeasureHour]
MN=[MeasureMin]
PElaps=[MeasurePercElaps:0%]
;MEASURES===================
[MeasureHour]
measure=time
format=%H
[MeasureMin]
measure=time
format=%M
[MeasurePercElaps]
measure=calc
formula=(((540 - (#OffWorkTime1# - ((#HR# * 60) + #MN#))) / 540) * 100)
MinValue=0
MaxValue=100
;METERS===================
[MeterBarPercent]
meter=bar
MeasureName=MeasurePercElaps
W=201
h=23
ValueRemainder=100
BarColor=84,165,196,255
BarOrientation=Horizontal
DynamicVariables=1
[MeterPercentDisplay]
meter=string
MeasureName=MeasurePercElaps
AntiAlias=1
NumOfDecimals=1
DynamicVariables=1
Postfix=% COMPLETE
It should be auto-refreshing every Update cycle, but instead the only way I can get it to refresh the values displayed is by manually refreshing it. It gives the correct value when refreshed, so I know the formulas aren't faulty, but it's just not updating automatically for some reason. The LeftMouseDownAction= thing I put in there doesn't work either. Any pointers you have would be much appreciated.
~δelta

You need to DynamicVariables=1 under the measure, [MeasurePercElaps] for it to keep updating.
Following script is more or less what are you trying to achieve but I just use a formula to calculate the % seconds left in 1 minute for an immediate effect.
;MEASURES===================
[MeasureHour]
measure=Time
format=%H
[MeasureMin]
measure=Time
format=%M
[MeasureSec]
measure=Time
format=%S
[MeasurePercElaps]
measure=Calc
;formula=(((540 - (#OffWorkTime1# - ((#HR# * 60) + #MN#))) / 540) * 100)
formula=((60.0-[MeasureSec])/60.0)*100.0
MinValue=0
MaxValue=100
DynamicVariables=1
[MeterBarPercent]
meter=Bar
MeasureName=MeasurePercElaps
AntiAlias=1
FontFace=#FontFace#
FontSize=12
SolidColor=47,47,47,255
StringAlign=Left
X=0
Y=0
W=190
H=20
ValueRemainder=100
BarColor=84,165,196,255
BarOrientation=Horizontal
DynamicVariables=1
[MeterPercentDisplay]
meter=String
MeasureName=MeasurePercElaps
AntiAlias=1
FontFace=#FontFace#
FontSize=12
FontColor=255,255,255,255
StringAlign=Left
X=0
Y=0
W=190
AntiAlias=1
NumOfDecimals=1
Postfix=% COMPLETE
DynamicVariables=1
The bar meter should be like below:
Since the [MeasurePercElaps] now can update itself, LeftMouseDownAction in the [Rainmeter] is not needed anymore. If you still put it there, it will lock you from moving the skin anywhere in your desktop area and you won't be able to open the skin's popup menu.
You can keep OnUpdateAction if you need to make your OffWorkTime variables persist on the next skin load/reload. But, I don't see the point, since you are only saving variables that are always constant during the skin session. It is what !WriteKeyValue bang is doing.
On the other hand, MiddleMouseDownAction is quite redundant.

Related

How to only animate the even frames in Abaqus?

I'm working on thermal simulations in Abaqus. I only need to animate the even frame numbers, so instead of the animation going 1,2,3,4,5 I need it to go 2,4,6,8,10.
Is there a way to only show the even frames? If so, how?
Go to Result --> Active Steps/Frames and deselect the frames that you don't want to be displayed and animated.
You can easily do this using Abaqus Python script.
Following is the overview of steps:
# getting current viewport object
vpName = session.currentViewportName
viewport = session.viewports[vpName]
# get odb object from viewport
odb= viewport.displayedObject
# Get all the steps available in the odb
stepNames = odb.steps.keys()
# Create animation object
ani = session.ImageAnimation(fileName='animation' ,format=AVI)
# add required frame to the animation object
for stepName in stepNames:
stpID = odb.steps[stepName].number - 1
nfrm = len(odb.steps[stp].frames)
for frmID in range(0, nfrm, 2): # 2 --> even frames will be added
viewport.odbDisplay.setFrame(step=stpID,frame=frmID)
ani.writeFrame(canvasObjects=(viewport, ))
ani.close()

Quick explanation, what is code behind $ in regards to x and y? (very short example using AutoIt)

Being new to programming, AutoIt using Imagesearch
$result = _ImageSearch("flowr.png",1,$x1,$y1,100)
having saved the desired imagine, what does
the 1 after the image-name mean?
(1 click) $x1 and $y1 mean
(coordinates for that 1x click) the 100 the speed?
The line of code began with
#include <ImageSearch.au3>
$x1=0
$y1=0
what is the $x1=0 here?
I'd love to just use google and type in "what does $x1=0 mean" but the translation of it yields a completely different answer and has nothing to do with coding^^
Thank you very much for clarifying!
The 1 after the flowername seems to be the tolerance, a value from 0-255 according to this documentation I found here
; Description: Find the position of an image on the desktop
; Syntax: _ImageSearchArea, _ImageSearch
; Parameter(s):
; $findImage - the image to locate on the desktop
; $tolerance - 0 for no tolerance (0-255). Needed when colors of
; image differ from desktop. e.g GIF
; $resultPosition - Set where the returned x,y location of the image is.
; 1 for centre of image, 0 for top left of image
; $x $y - Return the x and y location of the image
;
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0
The lines like $x1 = 0 are simple assignment operations. You are saving the value 0 in the variable $x1. You can later add, subtract, multiply, etc. using that value or store some other calculation which makes your program easy to alter.
You should try some examples to get the basics of programming down before diving in to an image search program. If all else fails though you can always check the Documentation.

unity3d - Change Image.fillAmount

I have an image acting as a health bar, and i want to give it a cistume value more than 1:
public Image healthBar;
// Use this for initialization
void Start () {
float health = 4;
healthBar.fillAmount = health;
Debug.Log (gameObject + ""+ healthBar.fillAmount);
}
Problem is no matter what value I give health, the fillAmount always goes back to 1. Is there any way to make it higher ?
fillAmount is a value of 0-1, with at 1 the full image being shown. There is no behavior yet for numbers over 1.
You could change the width of the image based on the maximum health and calculate the percentage that needs to be filled.
healthBar.rectTransform.rect.width = maxHealth * healthBarWidth;
healthBar.fillAmount = health / maxHealth;
If you don't want one bar, but multiple images like hearts that still are filled partially, you might be able to do it with a tiled image which automatically truncates at the edges.
I think you made a spelling error when creating the heath float. You call health when you declared "healt"
healthBar.fillAmount += health;
Try to do the increment in the fillAmount value, as it will assign the value you want it, and then change the code little bit in order to reach the exact number.

Creating Movie for each Generation of Data [duplicate]

This question already has an answer here:
How to create movies on each generation of a for loop in Matlab plot
(1 answer)
Closed 9 years ago.
I have the following code:
figure;
contour(X1,X2,f);
hold on
plot(top(1:size(top,1)), 'rx');
EDIT
figure;
for i = 1: G
contour(X1,X2,f);
hold on
plot(top(1:size(top,1)), 'rx');
end
NB: G is the maximum generation.
This is supposed to plot contours of sphere superimposed with selected individuals. In each iteration of the individuals, the best individuals is selected and these going on until the global optimum is reached. I need to show this in a movie form as shown in this below:
When you runs each stage of the iteration is indicated in the slides attached. This is what i am trying to do. Any idea please?
OK, I am just copying and pasting now, from here.
However I added FrameRate (per second) since you might want to use (or ask) it later.
writerObj = VideoWriter('Your_video.avi');
writerObj .FrameRate = 1; % 1 frames per second animation.
open(writerObj);
fig_h = figure;
for i = 1: G
contour(X1,X2,f);
hold on
plot(top(1:size(top,1)), 'rx');
frame = getframe(fig_h); % or frame = getframe; since getframe gets gcf.
writeVideo(writerObj, frame);
end
close(writerObj);
Now you will have a Your_video.avi file in your working directory.
If VideoWriter is not supported by your matlab, you could use use avifile same as mentioned in this answer (or in mathwork documentaion example here) like this:
aviobj = avifile('Your_video.avi','compression','None', 'fps', 1);
fig_h = figure;
for i = 1:G
contour(X1,X2,f);
hold on
plot(top(1:size(top,1)), 'rx');
frame = getframe(fig_h); % or frame = getframe; since getframe gets gcf.
aviobj = addframe(aviobj, frame);
end
aviobj = close(aviobj);
EDIT
A problem may occur as pointed out by this question also, which is the captured frame is a constant image. If you are running Matlab on windows, this problem may be caused by conjunction of windows in with certain graphics drivers, and may be solved as mentioned in this answer.

string/number from TextField to be used for calculation?

sorry for my question and for the long explanation following here, probably there's a simple solution for someone who is experienced in Cocoa and Objective-C, but I'm just starting few weeks ago and I can't figure out how to get this thing working, Grrrrrrr!!
OK, let's put it like this, in my window I have the following:
2 TextField(NSTextField) called:
blockOffText
blockOnText
1 Label(NSTextField) called:
flightTimeText
1 button(NSButton) called:
updateButton
What I want to do is all about time calculation I guess, get the "start-time" in one TextField and the "end-time" in the other.
One is supposed to be the "takeoff-time" and the other the "landing-time" or for example the "duty-startTime" and "duty-endTime"...it's the same!
Then I want to calculate the "flight-time" or "duty-time" and show it in the Label.
At the end I will also need to store the value or the time in a database as an integer, the value should be represented by all minutes corresponding to each time, but the database part is not a problem at the moment.
Maybe I can write the number in the TextField without the format but just the number and get the time show-up formatted in some way?
I would like to write for example "1245" and "1525" without having the needs to put the ":" between the hours and minutes, then can I get the value formatted "12:45" "15:25" in the TextField in some way? Maybe after pressing the button?
Ok, that is a second problem anyway, my real problem is I need to get the value I wrote in the TextField ("1245" and "1525") to be assigned to some variables in the program that I called "BlockOff" and "BlockOn".
I need to transform them in an integer that represent the minutes corresponding to their value..example:
The 1245 will become 765 minutes...(12 times 60 + 45)
and 1525 will become 925 minutes...(15 times 60 + 25)
HOW CAN I DO THIS?
In this way I can use the minutes to calculate the difference to get the flight time or even add flight time to other flight time.
At the moment my program works a little bit differently... like this:
If I directly assign the value to the two variables:
int blockOff = 765;
int blockOn = 925;
then I can calculate and show in the two TextField the takeOff and landing time formatted like I want: "12:45" "15:25"...I use other 2 variables to do so:
int oreBlkOff, minBlkOff = 0;
minBlkOff = blockOff % 60;
oreBlkOff = (blockOff - minBlkOff) / 60;
Then I can show the value in the TextField:
[blockOffText setStringValue:[NSString stringWithFormat: #"%d:%d", oreBlkOff, minBlkOff]];
Same with blockOnText and flightTimeText, so there is no problem there, but this is not really what I need right?
HOW CAN I GET THE VALUE OF THE TEXTFIELD AND STORE THE VALUE IN VARIABLES THAT CAN BE USED TO DO CALCULATION?
HOW DO I GET THE FIRST TO DIGITS AND LAST TO DIGITS FROM THE VARIABLES SO I CAN USE THEM AS HOURS AND MINUTES FOR MY CALCULATION?
I WOULD LIKE TO BE ABLE TO TYPE THE VALUE IN THE TEXTFIELD, PRESS "ENTER" OR "RETURN" AND GET THE VALUE ASSIGNED IN THE VARIABLE.
IS THIS THE CORRECT WAY OR I'M JUST GOING THE WRONG WAY IN THIS.
IN ANOTHER PROGRAM I DID IN VISUAL BASIC THAT WAS THE WAY I USED.
THANK YOU VERY MUCH IN ADVANCE FOR YOU HELP!
Gianluca
To get the int value from text field you'd use integerValue or floatValue for float. But you should definitely check out the date/time controls in cocoa.
Ok, if I didn't miss the point of your long question...
You have a text field with something like #"2345:8743" and you want to get the two numbers in int variables (a=2345, b=8743).
First you need to get these two text representations of your numbers in two NSStrings. You can do it like this:
NSString * yourString = #"2345:8743";
NSString *stringA = [yourString substringToIndex:4]; //stringA = #"2345"
NSString *stringB = [yourString substringFromIndex:5]; //stringB = #"8743";
Now to get the in values, just do:
int a = [stringA intValue];
int b = [stringB intValue];
Let me know if that is helpful to you.

Resources