It is currently March 28th, 2024, 5:17 pm

Building Managment

General topics related to Rainmeter.
GlassBuddah
Posts: 9
Joined: April 10th, 2017, 4:01 pm

Re: Building Managment

Post by GlassBuddah »

So I have been fiddling around with this and I have made some progress. However, I'm trying to figure out a part of the calculation. I need to make it so that the calculation so that it does not include the rooms that are set to #Bad#. So what I was thinking was having the calculation be a dynamic variable that pulls from a separate document, similar to the document that holds all the variables. All rooms set as #OK# and #Good# would be copied onto that document. This seems a bit complicated though, bringing in a couple other documents, is there a more streamlined way of doing this? Any suggestions would be appreciated!
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Building Managment

Post by CyberTheWorm »

best thing you can do is post your code so we can see what your are trying to do.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Building Managment

Post by eclectic-tech »

GlassBuddah wrote:So I have been fiddling around with this and I have made some progress. However, I'm trying to figure out a part of the calculation. I need to make it so that the calculation so that it does not include the rooms that are set to #Bad#. So what I was thinking was having the calculation be a dynamic variable that pulls from a separate document, similar to the document that holds all the variables. All rooms set as #OK# and #Good# would be copied onto that document. This seems a bit complicated though, bringing in a couple other documents, is there a more streamlined way of doing this? Any suggestions would be appreciated!
Interesting project...

@CyberTheWorm Hope you don't mind if I jump in with a few thoughts... :D

@GlassBuddah

There is no need to create more than just the one included 'roomstate.inc' file. It can contain all the details you need to calculate the desired results. I would place it in a @Resources folder of your skin.

I would set it up similar to this for as many rooms as you need, using plain text for room state and occupant names:
(The only requirement is the 'state' MUST be ALL CAPITALS to allow proper matching)

Code: Select all

;RoomState.inc
[Variables]
; Set this to the total number of rooms
NumberOfRooms=20

; Red for BAD
Color1=255,0,0,210
; Yellow for OK
Color2=255,255,28,210
; Green for GOOD
Color3=0,255,0,210

; ** IMPORTANT** 
; Use ALL CAPITAL LETTERS for Stateroom 
; Condition of BAD, OK, or GOOD
; Qty is number of occupants (0~2)
; 1.1 and 1.2 are occupant names for each room
StateRoom1=BAD
QtyRoom1=0
1.1=
1.2=

StateRoom2=OK
QtyRoom2=1
2.1=Weston
2.2=

StateRoom3=GOOD
QtyRoom3=1
3.1=Smith
3.2=

...
Then use a few new variables and measures in a main skin to obtain the results wanted.

Code: Select all

[Variables]
;Variables are set in these files
@Include1="#@#RoomState.inc"
; These are changed by the skin measures {Do not change}
NA=0
OK=0
GOOD=0

;-------------------- Measures ----------------------
; Measure the number of occupants
[MeasureQty]
Measure=calc
Formula=(#QtyRoom1#+#QtyRoom2#+#QtyRoom3#+#QtyRoom4#+#QtyRoom5#+#QtyRoom6#+#QtyRoom7#+#QtyRoom8#+#QtyRoom9#+#QtyRoom10#+#QtyRoom11#+#QtyRoom12#+#QtyRoom13#+#QtyRoom14#+#QtyRoom15#+#QtyRoom16#+#QtyRoom17#+#QtyRoom18#+#QtyRoom19#+#QtyRoom20#)

; Measure the number of available spaces and GOOD rooms
[MeasureAvailable]
Measure=calc
Formula=(#NumberOfRooms#*2)-(#NA#*2)
OnUpdateAction=[!SetVariable Good (#NumberOfRooms#-#NA#-#OK#)]
DynamicVariables=1

; Measure the percentage of occupant based on available spaces
[MeasureQtyPercent]
Measure=calc
Formula=(MeasureQty/MeasureAvailable)

; Measure the percent of functional rooms
[MeasureFunctional]
Measure=calc
Formula=1-#NA#/#NumberOfRooms#
DynamicVariables=1

;------ Measure Room States ----------------------------------

[MeasureRoom1State]
Measure=String
String=#StateRoom1#
; Change the color based on state
Substitute="BAD":"#Color1#","OK":"#Color2#","GOOD":"#Color3#"
; Collate Not Available and Functional
IfMatch=#Color1#
IfMatchAction=[!SetVariable NA (#NA#+1)]
IfMatch2=#Color2#
IfMatchAction2=[!SetVariable OK (#OK#+1)]
DynamicVariables=1

[MeasureRoom2State]
Measure=String
String=#StateRoom2#
Substitute="BAD":"#Color1#","OK":"#Color2#","GOOD":"#Color3#"
IfMatch=#Color1#
IfMatchAction=[!SetVariable NA (#NA#+1)]
IfMatch2=#Color2#
IfMatchAction2=[!SetVariable OK (#OK#+1)]
DynamicVariables=1

...
Add as many [MeasureRoom#State] measures as the number of rooms. I use the IfMatch to match the substituted color and increase the NA or OK variables if they match.

You can use MeterStyle to simplify AND by using room numbers as the section name, save a lot of typing:

Code: Select all

;-------------- Meter Style -----------------------
; This is added to each room meter. The section names MUST be the room number
[RoomStyle]
X=4R
Y=r
Shape=Rectangle 0,0,40,80 | StrokeWidth 0 | Fill Color [MeasureRoom#CurrentSection#State]
DynamicVariables=1
ToolTipType=1
ToolTipTitle="Occupants"

Then display the information as you want:

Code: Select all

;-------------------- Meters ----------------------
[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,500,500 | Fill color 27,27,27,255 | StrokeWidth 2 | Stroke Color 200,200,200,255
X=1
Y=1

[MeterQtyLabel]
Meter=String
MeasureName=MeasureQtyPercent
X=130
Y=20
FontColor=255,255,255,255
AntiAlias=1
Percentual=1
StringAlign=Left
Text="Occupancy: %1%"

[MeterQty]
Meter=BAR
MeasureName=MeasureQtyPercent
X=1r
Y=20r
W=250
H=30
BarColor=0,255,0,210
SolidColor=150,150,150,255
BarOrientation=Horizontal

[MeterFunctionalLabel]
Meter=String
MeasureName=MeasureFunctional
X=130
Y=20R
FontColor=255,255,255,255
AntiAlias=1
Percentual=1
StringAlign=Left
Text=Functional: %1% Good: #Good# | Ok: #Ok# | Bad: #NA#
DynamicVariables=1

[MeterFunctional]
Meter=BAR
MeasureName=MeasureFunctional
X=1r
Y=20r
W=250
H=30
BarColor=0,255,0,210
SolidColor=250,0,0,255
BarOrientation=Horizontal

;------------------Room Meters -----------------
[1]
Meter=Shape
MeterStyle=RoomStyle
X=30
Y=200
ToolTipText=#1.1##CRLF##1.2#

[2]
Meter=Shape
MeterStyle=RoomStyle
ToolTipText=#2.1##CRLF##2.2#

...
Add more shape meters to match the number of rooms. Remember to name the section the room number!
The unique tooltip and style are all that is needed unless you want to re-position the meter (to make a second row).

Gives you something like this (Occupant names will appear on mouse over in a tool tip):
dormitory.png
This ticks all the boxes you mentioned, but putting it all together will require a bit more typing...

As @CyberThe Worm said, we can't help very much without seeing the code you have so far, so we can only guess how far you are?
Depending on that, you may not need any of this... :uhuh:
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Building Managment

Post by CyberTheWorm »

eclectic-tech wrote:@CyberTheWorm Hope you don't mind if I jump in with a few thoughts... :D
Go for it I just did a quick thing your's is better
GlassBuddah
Posts: 9
Joined: April 10th, 2017, 4:01 pm

Re: Building Managment

Post by GlassBuddah »

Wow, again thank you guys for all the help. Sorry I didn't reply, I had been without internet for a bit (thanks base internet). I was had gotten the list part down, I was just having issues with summing the content of a table. So for each room I had a bit of code that looked like this (with the room number changed accordingly).

IfCondition = (Room1State ~= #Good#)
IfTrueAction = table.insert (DownRooms, Room1State)
IfCondition = (Room1State ~= #Bad#)
IfTrueAction = table.insert (OccupiableRooms, Room1Qty)


This established two tables for me, one for functionality and one for occupancy. However I couldn't find anything in the standard library how to sum a table, and I have been spending some time working on trying to figure it out.
GlassBuddah
Posts: 9
Joined: April 10th, 2017, 4:01 pm

Re: Building Managment

Post by GlassBuddah »

I also hadn't really made it that far, this was put a bit on back burner, shattered his foot and had surgery, so I have been mostly just been his man servant for a bit, but he's gone now so I have started working on this once more.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Building Managment

Post by eclectic-tech »

GlassBuddah wrote:Wow, again thank you guys for all the help. Sorry I didn't reply, I had been without internet for a bit (thanks base internet). I was had gotten the list part down, I was just having issues with summing the content of a table. So for each room I had a bit of code that looked like this (with the room number changed accordingly).

IfCondition = (Room1State ~= #Good#)
IfTrueAction = table.insert (DownRooms, Room1State)
IfCondition = (Room1State ~= #Bad#)
IfTrueAction = table.insert (OccupiableRooms, Room1Qty)


This established two tables for me, one for functionality and one for occupancy. However I couldn't find anything in the standard library how to sum a table, and I have been spending some time working on trying to figure it out.
The code you posted is not enough to see what you are doing, and as it is, will not work. :uhuh:

The code I posted will calculate all of the numbers you want: rooms 'good' | 'ok' | 'bad', the number (percentage) of occupancy, names in rooms, etc. Try to build on that code and you should be able to create your project :welcome:

Or post all of your code so people can see what you have to correct...
Post Reply