Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated base URL for OSISoft documentation #591

Merged
merged 7 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PIconnect/PIAF.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
from warnings import warn

from PIconnect._operators import OPERATORS, add_operators
from PIconnect._utils import classproperty
from PIconnect.AFSDK import AF
from PIconnect.PIData import PISeriesContainer
from PIconnect.time import timestamp_to_index
from PIconnect._utils import classproperty

_NOTHING = object()

Expand Down
14 changes: 7 additions & 7 deletions PIconnect/PIConsts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class UpdateMode(IntEnum):
"""Indicates how to treat duplicate values in the archive, when supported by the Data Reference.

Detailed information is available at https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/T_OSIsoft_AF_Data_AFUpdateOption.htm
Detailed information is available at https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFUpdateOption.htm
"""

#: Add the value to the archive.
Expand All @@ -36,7 +36,7 @@ class UpdateMode(IntEnum):
class BufferMode(IntEnum):
"""Indicates buffering option in updating values, when supported by the Data Reference.

Detailed information is available at https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/T_OSIsoft_AF_Data_AFBufferOption.htm
Detailed information is available at https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFBufferOption.htm
"""

#: Updating data reference values without buffer.
Expand All @@ -52,7 +52,7 @@ class BufferMode(IntEnum):
class AuthenticationMode(IntEnum):
"""AuthenticationMode indicates how a user authenticates to a PI Server

Detailed information is available at https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/T_OSIsoft_AF_PI_PIAuthenticationMode.htm
Detailed information is available at https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_PI_PIAuthenticationMode.htm
"""

#: Use Windows authentication when making a connection
Expand All @@ -64,7 +64,7 @@ class AuthenticationMode(IntEnum):
class CalculationBasis(IntEnum):
"""CalculationBasis indicates how values should be weighted over a time range

Detailed information is available at https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/T_OSIsoft_AF_Data_AFCalculationBasis.htm
Detailed information is available at https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFCalculationBasis.htm
"""

#: Each event is weighted according to the time over which it applies.
Expand All @@ -86,7 +86,7 @@ class CalculationBasis(IntEnum):
class ExpressionSampleType(IntEnum):
"""ExpressionSampleType indicates how expressions are evaluated over a time range.

Detailed information is available at https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/T_OSIsoft_AF_Data_AFSampleType.htm
Detailed information is available at https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFSampleType.htm
"""

#: The expression is evaluated at each archive event.
Expand All @@ -106,7 +106,7 @@ class SummaryType(IntFlag):
<SummaryType.MAXIMUM|MINIMUM: 12> # On Python 3.6+
12 # On previous versions

Detailed information is available at https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/T_OSIsoft_AF_Data_AFSummaryTypes.htm
Detailed information is available at https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFSummaryTypes.htm
"""

#: No summary data
Expand Down Expand Up @@ -141,7 +141,7 @@ class TimestampCalculation(IntEnum):
"""
TimestampCalculation defines the timestamp returned for a given summary calculation

Detailed information is available at https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/T_OSIsoft_AF_Data_AFTimestampCalculation.htm
Detailed information is available at https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFTimestampCalculation.htm
"""

#: The timestamp is the event time of the minimum or maximum for those summaries or the beginning of the interval otherwise.
Expand Down
28 changes: 17 additions & 11 deletions PIconnect/time.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
from datetime import datetime

import pytz

from PIconnect.AFSDK import AF
from PIconnect.config import PIConfig


def to_af_time_range(start_time, end_time):
"""to_af_time_range
"""Convert a combination of start and end time to a time range.

Return AF.Time.AFTimeRange object from datetime or string
using :afsdk:`AF.Time.AFTimeRange <M_OSIsoft_AF_Time_AFTimeRange__ctor_1.htm>`.
Both `start_time` and `end_time` can be either a :any:`datetime.datetime` object or a string.
`datetime` objects are first converted to a string, before being passed to
:afsdk:`AF.Time.AFTimeRange <M_OSIsoft_AF_Time_AFTimeRange__ctor_1.htm>`. It is also
possible to specify either end as a `datetime` object, and then specify the other
boundary as a relative string.

If string is used, it is assumed that user knows the format
that should be passed to AF.Time.AFTimeRange.
"""
Args:
start_time (str | datetime): Start time of the time range.
end_time (str | datetime): End time of the time range.

Returns:
:afsdk:`AF.Time.AFTimeRange <M_OSIsoft_AF_Time_AFTimeRange__ctor_1.htm>`: Time range covered by the start and end time.
"""
if isinstance(start_time, datetime):
start_time = start_time.isoformat()
if isinstance(end_time, datetime):
Expand All @@ -26,12 +33,11 @@ def to_af_time_range(start_time, end_time):
def timestamp_to_index(timestamp):
"""Convert AFTime object to datetime in local timezone.

.. todo::

Allow to define timezone, default to UTC?

.. todo::
Args:
timestamp (`System.DateTime`): Timestamp in .NET format to convert to `datetime`.

Returns:
`datetime`: Datetime with the timezone info from :data:`PIConfig.DEFAULT_TIMEZONE <PIconnect.config.PIConfigContainer.DEFAULT_TIMEZONE>`.
"""
local_tz = pytz.timezone(PIConfig.DEFAULT_TIMEZONE)
return (
Expand Down
8 changes: 0 additions & 8 deletions docs/PIconnect.PI.rst

This file was deleted.

20 changes: 0 additions & 20 deletions docs/PIconnect.rst

This file was deleted.

21 changes: 21 additions & 0 deletions docs/api/PI/PIconnect.PI.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PIconnect.PI module
===================

.. autoclass:: PIconnect.PI.PIServer
:members:
:undoc-members:
:inherited-members:
:show-inheritance:
:exclude-members: servers, default_server

.. autoattribute:: servers
:annotation: Dictionary of known servers, as reported by the SDK

.. autoattribute:: default_server
:annotation: Default server, as reported by the SDK

.. autoclass:: PIconnect.PI.PIPoint
:members:
:undoc-members:
:inherited-members:
:show-inheritance:
27 changes: 27 additions & 0 deletions docs/api/PIAF/PIconnect.PIAF.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
PIconnect.PIAF module
=====================

.. autoclass:: PIconnect.PIAF.PIAFDatabase
:members:
:undoc-members:
:inherited-members:
:show-inheritance:
:exclude-members: servers, default_server

.. autoattribute:: servers
:annotation: Dictionary of known servers, as reported by the SDK

.. autoattribute:: default_server
:annotation: Default server, as reported by the SDK

.. autoclass:: PIconnect.PIAF.PIAFElement
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

.. autoclass:: PIconnect.PIAF.PIAFAttribute
:members:
:undoc-members:
:inherited-members:
:show-inheritance:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/PIconnect.PIAF.rst → docs/api/PIconnect.time.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PIconnect.PIAF module
PIconnect.time module
=====================

.. automodule:: PIconnect.PIAF
.. automodule:: PIconnect.time
:members:
:undoc-members:
:inherited-members:
Expand Down
35 changes: 35 additions & 0 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
API Reference
=============

.. automodule:: PIconnect
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

PI Data Archive related modules
-------------------------------

.. toctree::
:maxdepth: 4
:glob:

./PI/*

PI Asset Framework related modules
----------------------------------

.. toctree::
:maxdepth: 4
:glob:

./PIAF/*

Generic utility modules
-----------------------

.. toctree::
:maxdepth: 4
:glob:

./*
21 changes: 10 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import PIconnect

# sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))


class Mock(MagicMock):
Expand All @@ -35,14 +33,15 @@ def __getattr__(cls, name):
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
project_root = os.path.dirname(cwd)
# cwd = os.getcwd()
# project_root = os.path.dirname(cwd)

# Insert the project root dir as the first element in the PYTHONPATH.
# This lets us ensure that the source package is imported, and that its
# version is used.
sys.path.insert(0, project_root)
# sys.path.insert(0, project_root)

import PIconnect

# -- General configuration ---------------------------------------------

Expand All @@ -55,6 +54,7 @@ def __getattr__(cls, name):
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.githubpages",
Expand Down Expand Up @@ -89,12 +89,11 @@ def __getattr__(cls, name):
# The full version, including alpha/beta/rc tags.
release = PIconnect.__version__

extlinks = {
"afsdk": ("https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/%s", "")
}
extlinks = {"afsdk": ("https://docs.osisoft.com/bundle/af-sdk/page/html/%s", "")}

intersphinx_mapping = {
"pandas": ("http://pandas.pydata.org/docs", None),
"python": ("https://docs.python.org/3.8", None),
"pandas": ("https://pandas.pydata.org/docs", None),
"pytz": ("http://pytz.sourceforge.net", None),
}

Expand All @@ -116,7 +115,7 @@ def __getattr__(cls, name):
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True


autosummary_generate = True
# -- Options for HTML output ----------------------------------------------


Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ structure:
- The basic introductions to using :py:mod:`PIconnect` are covered in the
:doc:`/tutorials`.
- The technical reference to all modules within :py:mod:`PIconnect` are
covered in :doc:`/modules`. These also include several links to the original
covered in :doc:`/api/index`. These also include several links to the original
SDK documentation for important implementation details.
- Background explanations and how-to guides still need to be written.

Expand All @@ -26,7 +26,7 @@ Contents

installation
tutorials
modules
api/index
contributing
authors
history
Expand Down
7 changes: 0 additions & 7 deletions docs/modules.rst

This file was deleted.

1 change: 1 addition & 0 deletions docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ Data extraction
tutorials/interpolated_values
tutorials/summaries
tutorials/timezones
tutorials/update_value
1 change: 1 addition & 0 deletions docs/tutorials/update_value.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ buffer_option as AFBufferOption.


.. code-block:: python

from datetime import datetime
import pytz
import PIconnect as PI
Expand Down