File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616if os .environ .get ('DSS_EXTENSIONS_DEBUG' , '' ) != '1' :
1717 altdss_lib_path = altdss_lib_parent_path .joinpath ('libaltdss_capi.so' )
18- pass
1918else :
2019 import warnings
2120 warnings .warn ('Environment variable DSS_EXTENSIONS_DEBUG=1 is set: loading the debug version of the DSS C-API library' )
2221 altdss_lib_path = altdss_lib_parent_path .joinpath ('libaltdss_capid.so' )
23- pass
24-
2522
2623if not altdss_lib_path .exists ():
2724 raise RuntimeError ('AltDSS library not found!' )
2825
29-
3026# Basic initialization -- load the library and prepare the structures
3127lib = _altdss_capi_loader .ffi .new ('AltDSSCAPI*' )
3228
4440if _init_result != 1 :
4541 raise RuntimeError (f'AltDSS library found but could not be loaded (code { _init_result } )!' )
4642
47- # Ensure this is called at least once. This was moved from
43+ # For AltDSS, ensure this is called at least once. This was moved from
4844# CffiApiUtil so we call it as soon as the DLL/so is loaded.
4945lib .DSS_Start (ffi .NULL , 0 )
5046
Original file line number Diff line number Diff line change 1+ '''
2+ This file provides access to the Oddie library.
3+ Note that it does not initialize the OpenDSS or OpenDSS-C libraries, that is a
4+ second step. The same Oddie instance can be used to load multiple engine libraries.
5+ '''
6+ import os
7+ from . import _altdss_capi_loader
8+ from ._altdss_capi_loader import ffi , lib as loader_lib
9+ from pathlib import Path
10+
11+ altdss_lib_parent_path = Path (_altdss_capi_loader .__file__ ).absolute ().parent
12+
13+ if os .environ .get ('DSS_EXTENSIONS_DEBUG' , '' ) != '1' :
14+ oddie_lib_path = altdss_lib_parent_path .joinpath ('libaltdss_oddie_capi.so' )
15+ else :
16+ import warnings
17+ warnings .warn ('Environment variable DSS_EXTENSIONS_DEBUG=1 is set: loading the debug version of the AltDSS Oddie library' )
18+ oddie_lib_path = altdss_lib_parent_path .joinpath ('libaltdss_oddie_capid.so' )
19+
20+ if not oddie_lib_path .exists ():
21+ print (oddie_lib_path )
22+ raise RuntimeError ('Oddie library not found!' )
23+
24+ # Basic initialization -- load the library and prepare the structures
25+ lib = _altdss_capi_loader .ffi .new ('AltDSSCAPI*' )
26+
27+ _init_result = loader_lib .AltDSSCAPILibInit (
28+ str (oddie_lib_path ).encode (),
29+ ffi .NULL ,
30+ b"AltDSSOddieCAPIInit" ,
31+ lib ,
32+ ffi .sizeof (lib [0 ]),
33+ 0 ,
34+ 0 ,
35+ ffi .NULL
36+ )
37+
38+ if _init_result != 1 :
39+ raise RuntimeError (f'Oddie library found but could not be loaded (code { _init_result } )!' )
40+
41+ # Compared to the main "lib" in __init__.py, we will not call DSS_Start yet
42+ # since the actual engine is not loaded.
You can’t perform that action at this time.
0 commit comments