Skip to content

Commit

Permalink
fix(hvac): Improve message when Ironbug exe access is denied
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Jun 19, 2023
1 parent 8dd4ad8 commit 827c596
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Binary file modified honeybee_grasshopper_energy/icon/HB Detailed HVAC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions honeybee_grasshopper_energy/json/HB_Detailed_HVAC.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.6.1",
"nickname": "DetailedHVAC",
"outputs": [
[
Expand Down Expand Up @@ -43,7 +43,7 @@
}
],
"subcategory": "4 :: HVAC",
"code": "\nimport json\n\ntry: # import the honeybee extension\n from honeybee.typing import clean_and_id_ep_string, clean_ep_string\n from honeybee.model import Model\n from honeybee.room import Room\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the honeybee-energy extension\n from honeybee_energy.config import folders\n from honeybee_energy.hvac.detailed import DetailedHVAC\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, give_warning\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\nif folders.ironbug_exe is None:\n msg = 'An installation of Ironbug that is compatible with this component\\n' \\\n 'was not found on this machine. This component will not be usable.'\n print(msg)\n give_warning(ghenv.Component, msg)\nelif folders.ironbug_version is not None:\n if folders.ironbug_version < (1, 5, 3):\n msg = 'Ironbug version \"{}\" is not compatible with this component.\\n' \\\n 'This component will not be usable.'.format(\n '.'.join([str(i) for i in folders.ironbug_version]))\n print(msg)\n give_warning(ghenv.Component, msg)\n\n\nif all_required_inputs(ghenv.Component):\n # extract any rooms from input Models and duplicate the rooms\n rooms, hb_objs = [], []\n for hb_obj in _hb_objs:\n if isinstance(hb_obj, Model):\n new_obj = hb_obj.duplicate()\n hb_objs.append(new_obj)\n rooms.extend(new_obj.rooms)\n elif isinstance(hb_obj, Room):\n new_obj = hb_obj.duplicate()\n hb_objs.append(new_obj)\n rooms.append(new_obj)\n else:\n raise ValueError(\n 'Expected Honeybee Room or Model. Got {}.'.format(type(hb_obj)))\n\n # create the HVAC\n name = clean_and_id_ep_string('Detailed HVAC') if _name_ is None else \\\n clean_ep_string(_name_)\n specification = json.loads(_hvac_system.ToJson())\n hvac = DetailedHVAC(name, specification)\n if _name_ is not None:\n hvac.display_name = _name_\n\n # apply the HVAC system to the rooms\n hvac_rooms = set(hvac.thermal_zones)\n hvac_count, rel_rooms = 0, []\n for room in rooms:\n if room.identifier in hvac_rooms:\n room.properties.energy.hvac = hvac\n rel_rooms.append(room.identifier)\n hvac_count += 1\n\n # give a warning if no rooms were assigned the HVAC or if there are missing rooms\n if hvac_count == 0:\n msg = 'None of the connected Rooms are referenced under the Ironbug HVAC system.\\n' \\\n 'Make sure that the system has been set up with the correct Rooms.'\n print(msg)\n give_warning(ghenv.Component, msg)\n if len(rel_rooms) != len(hvac_rooms):\n missing_rooms = []\n found_rooms = set(rel_rooms)\n for rm_id in hvac_rooms:\n if rm_id not in found_rooms:\n missing_rooms.append(rm_id)\n msg = 'The Ironbug HVAC system contains the following rooms that are not ' \\\n 'in the connected _hb_objs.\\n{}'.format('\\n'.join(missing_rooms))\n print(msg)\n give_warning(ghenv.Component, msg)\n",
"code": "\nimport json\n\ntry: # import the honeybee extension\n from honeybee.typing import clean_and_id_ep_string, clean_ep_string\n from honeybee.model import Model\n from honeybee.room import Room\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the honeybee-energy extension\n from honeybee_energy.config import folders\n from honeybee_energy.hvac.detailed import DetailedHVAC\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_energy:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, give_warning\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\nif folders.ironbug_exe is None:\n msg = 'An installation of Ironbug that is compatible with this component\\n' \\\n 'was not found on this machine. This component will not be usable.'\n print(msg)\n give_warning(ghenv.Component, msg)\nelif folders.ironbug_version is not None:\n if folders.ironbug_version < (1, 9, 1):\n msg = 'Ironbug version \"{}\" is not compatible with this component.\\n' \\\n 'This component will not be usable.'.format(\n '.'.join([str(i) for i in folders.ironbug_version]))\n print(msg)\n give_warning(ghenv.Component, msg)\nelse:\n msg = 'An installation of Ironbug was found at: {}\\nbut it is not ' \\\n 'accessible. Contact your adminstrator.'.format(folders.ironbug_exe)\n print(msg)\n give_warning(ghenv.Component, msg)\n\n\nif all_required_inputs(ghenv.Component):\n # extract any rooms from input Models and duplicate the rooms\n rooms, hb_objs = [], []\n for hb_obj in _hb_objs:\n if isinstance(hb_obj, Model):\n new_obj = hb_obj.duplicate()\n hb_objs.append(new_obj)\n rooms.extend(new_obj.rooms)\n elif isinstance(hb_obj, Room):\n new_obj = hb_obj.duplicate()\n hb_objs.append(new_obj)\n rooms.append(new_obj)\n else:\n raise ValueError(\n 'Expected Honeybee Room or Model. Got {}.'.format(type(hb_obj)))\n\n # create the HVAC\n name = clean_and_id_ep_string('Detailed HVAC') if _name_ is None else \\\n clean_ep_string(_name_)\n specification = json.loads(_hvac_system.ToJson())\n hvac = DetailedHVAC(name, specification)\n if _name_ is not None:\n hvac.display_name = _name_\n\n # apply the HVAC system to the rooms\n hvac_rooms = set(hvac.thermal_zones)\n hvac_count, rel_rooms = 0, []\n for room in rooms:\n if room.identifier in hvac_rooms:\n room.properties.energy.hvac = hvac\n rel_rooms.append(room.identifier)\n hvac_count += 1\n\n # give a warning if no rooms were assigned the HVAC or if there are missing rooms\n if hvac_count == 0:\n msg = 'None of the connected Rooms are referenced under the Ironbug HVAC system.\\n' \\\n 'Make sure that the system has been set up with the correct Rooms.'\n print(msg)\n give_warning(ghenv.Component, msg)\n if len(rel_rooms) != len(hvac_rooms):\n missing_rooms = []\n found_rooms = set(rel_rooms)\n for rm_id in hvac_rooms:\n if rm_id not in found_rooms:\n missing_rooms.append(rm_id)\n msg = 'The Ironbug HVAC system contains the following rooms that are not ' \\\n 'in the connected _hb_objs.\\n{}'.format('\\n'.join(missing_rooms))\n print(msg)\n give_warning(ghenv.Component, msg)\n",
"category": "HB-Energy",
"name": "HB Detailed HVAC",
"description": "Apply a detailed Ironbug HVAC to Honeybee Rooms or a Honeybee Model.\n-"
Expand Down
9 changes: 7 additions & 2 deletions honeybee_grasshopper_energy/src/HB Detailed HVAC.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

ghenv.Component.Name = "HB Detailed HVAC"
ghenv.Component.NickName = 'DetailedHVAC'
ghenv.Component.Message = '1.6.0'
ghenv.Component.Message = '1.6.1'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '4 :: HVAC'
ghenv.Component.AdditionalHelpFromDocStrings = '0'
Expand Down Expand Up @@ -59,12 +59,17 @@
print(msg)
give_warning(ghenv.Component, msg)
elif folders.ironbug_version is not None:
if folders.ironbug_version < (1, 5, 3):
if folders.ironbug_version < (1, 9, 1):
msg = 'Ironbug version "{}" is not compatible with this component.\n' \
'This component will not be usable.'.format(
'.'.join([str(i) for i in folders.ironbug_version]))
print(msg)
give_warning(ghenv.Component, msg)
else:
msg = 'An installation of Ironbug was found at: {}\nbut it is not ' \
'accessible. Contact your adminstrator.'.format(folders.ironbug_exe)
print(msg)
give_warning(ghenv.Component, msg)


if all_required_inputs(ghenv.Component):
Expand Down
Binary file modified honeybee_grasshopper_energy/user_objects/HB Detailed HVAC.ghuser
Binary file not shown.

0 comments on commit 827c596

Please sign in to comment.