Compare commits
7 Commits
master
...
postgresql
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9289a0b4a | ||
|
|
a0fd15bade | ||
|
|
b222c5370a | ||
|
|
53a3fc11ad | ||
|
|
7e0bd621f7 | ||
|
|
33a027a458 | ||
|
|
9cfbda3c18 |
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
||||
poc-java
|
||||
544
.idea/dbnavigator.xml
generated
Normal file
544
.idea/dbnavigator.xml
generated
Normal file
@@ -0,0 +1,544 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DBNavigator.Project.DataEditorManager">
|
||||
<record-view-column-sorting-type value="BY_INDEX" />
|
||||
<value-preview-text-wrapping value="false" />
|
||||
<value-preview-pinned value="false" />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DataExportManager">
|
||||
<export-instructions>
|
||||
<create-header value="true" />
|
||||
<quote-values-containing-separator value="true" />
|
||||
<quote-all-values value="false" />
|
||||
<value-separator value="" />
|
||||
<file-name value="" />
|
||||
<file-location value="" />
|
||||
<scope value="GLOBAL" />
|
||||
<destination value="FILE" />
|
||||
<format value="EXCEL" />
|
||||
<charset value="UTF-8" />
|
||||
</export-instructions>
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DatabaseBrowserManager">
|
||||
<autoscroll-to-editor value="false" />
|
||||
<autoscroll-from-editor value="true" />
|
||||
<show-object-properties value="true" />
|
||||
<loaded-nodes>
|
||||
<connection connection-id="94a6cabe-5b17-467d-a87c-dc17d3749f25">
|
||||
<schema name="information_schema" object-types="table" />
|
||||
<schema name="pg_catalog" object-types="table" />
|
||||
<schema name="public" object-types="table" />
|
||||
</connection>
|
||||
</loaded-nodes>
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DatabaseConsoleManager">
|
||||
<connection id="94a6cabe-5b17-467d-a87c-dc17d3749f25">
|
||||
<console name="LocalPostGreSQL" type="STANDARD" />
|
||||
</connection>
|
||||
</component>
|
||||
<component name="DBNavigator.Project.EditorStateManager">
|
||||
<last-used-providers />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.FileConnectionMappingManager">
|
||||
<mapping file-url="file://$PROJECT_DIR$/db_setup.sql" connection-id="94a6cabe-5b17-467d-a87c-dc17d3749f25" current-schema="information_schema" />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.MethodExecutionManager">
|
||||
<method-browser />
|
||||
<execution-history>
|
||||
<group-entries value="true" />
|
||||
<execution-inputs />
|
||||
</execution-history>
|
||||
<argument-values-cache />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.ObjectDependencyManager">
|
||||
<last-used-dependency-type value="INCOMING" />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.ObjectQuickFilterManager">
|
||||
<last-used-operator value="EQUAL" />
|
||||
<filters />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.ScriptExecutionManager" clear-outputs="true">
|
||||
<recently-used-interfaces>
|
||||
<mapping database-type="POSTGRES" interface-id="DEFAULT" />
|
||||
</recently-used-interfaces>
|
||||
</component>
|
||||
<component name="DBNavigator.Project.Settings">
|
||||
<connections>
|
||||
<connection id="94a6cabe-5b17-467d-a87c-dc17d3749f25" active="true">
|
||||
<database>
|
||||
<name value="LocalPostGreSQL" />
|
||||
<description value="LocalPostGreSQL" />
|
||||
<database-type value="POSTGRES" />
|
||||
<config-type value="BASIC" />
|
||||
<database-version value="9.6" />
|
||||
<driver-source value="BUILTIN" />
|
||||
<driver-library value="" />
|
||||
<driver value="" />
|
||||
<url-type value="DATABASE" />
|
||||
<host value="localhost" />
|
||||
<port value="5432" />
|
||||
<database value="poc" />
|
||||
<os-authentication value="true" />
|
||||
<empty-password value="false" />
|
||||
<user value="" />
|
||||
<password value="" />
|
||||
</database>
|
||||
<properties>
|
||||
<auto-commit value="false" />
|
||||
</properties>
|
||||
<ssh-settings>
|
||||
<active value="false" />
|
||||
<proxy-host value="" />
|
||||
<proxy-port value="22" />
|
||||
<proxy-user value="" />
|
||||
<proxy-password value="" />
|
||||
<auth-type value="PASSWORD" />
|
||||
<key-file value="" />
|
||||
<key-passphrase value="" />
|
||||
</ssh-settings>
|
||||
<details>
|
||||
<charset value="UTF-8" />
|
||||
<ddl-file-binding value="true" />
|
||||
<database-logging value="false" />
|
||||
<connect-automatically value="true" />
|
||||
<restore-workspace value="true" />
|
||||
<restore-workspace-deep value="true" />
|
||||
<environment-type value="default" />
|
||||
<idle-time-to-disconnect value="30" />
|
||||
<password-expiry-time value="10" />
|
||||
<max-connection-pool-size value="7" />
|
||||
<alternative-statement-delimiter value="" />
|
||||
</details>
|
||||
<object-filters hide-empty-schemas="false">
|
||||
<object-type-filter use-master-settings="true">
|
||||
<object-type name="SCHEMA" enabled="true" />
|
||||
<object-type name="USER" enabled="true" />
|
||||
<object-type name="ROLE" enabled="true" />
|
||||
<object-type name="PRIVILEGE" enabled="true" />
|
||||
<object-type name="CHARSET" enabled="true" />
|
||||
<object-type name="TABLE" enabled="true" />
|
||||
<object-type name="VIEW" enabled="true" />
|
||||
<object-type name="MATERIALIZED_VIEW" enabled="true" />
|
||||
<object-type name="NESTED_TABLE" enabled="true" />
|
||||
<object-type name="COLUMN" enabled="true" />
|
||||
<object-type name="INDEX" enabled="true" />
|
||||
<object-type name="CONSTRAINT" enabled="true" />
|
||||
<object-type name="DATASET_TRIGGER" enabled="true" />
|
||||
<object-type name="DATABASE_TRIGGER" enabled="true" />
|
||||
<object-type name="SYNONYM" enabled="true" />
|
||||
<object-type name="SEQUENCE" enabled="true" />
|
||||
<object-type name="PROCEDURE" enabled="true" />
|
||||
<object-type name="FUNCTION" enabled="true" />
|
||||
<object-type name="PACKAGE" enabled="true" />
|
||||
<object-type name="TYPE" enabled="true" />
|
||||
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
|
||||
<object-type name="ARGUMENT" enabled="true" />
|
||||
<object-type name="DIMENSION" enabled="true" />
|
||||
<object-type name="CLUSTER" enabled="true" />
|
||||
<object-type name="DBLINK" enabled="true" />
|
||||
</object-type-filter>
|
||||
<object-name-filters />
|
||||
</object-filters>
|
||||
</connection>
|
||||
</connections>
|
||||
<browser-settings>
|
||||
<general>
|
||||
<display-mode value="TABBED" />
|
||||
<navigation-history-size value="100" />
|
||||
<show-object-details value="false" />
|
||||
</general>
|
||||
<filters>
|
||||
<object-type-filter>
|
||||
<object-type name="SCHEMA" enabled="true" />
|
||||
<object-type name="USER" enabled="true" />
|
||||
<object-type name="ROLE" enabled="true" />
|
||||
<object-type name="PRIVILEGE" enabled="true" />
|
||||
<object-type name="CHARSET" enabled="true" />
|
||||
<object-type name="TABLE" enabled="true" />
|
||||
<object-type name="VIEW" enabled="true" />
|
||||
<object-type name="MATERIALIZED_VIEW" enabled="true" />
|
||||
<object-type name="NESTED_TABLE" enabled="true" />
|
||||
<object-type name="COLUMN" enabled="true" />
|
||||
<object-type name="INDEX" enabled="true" />
|
||||
<object-type name="CONSTRAINT" enabled="true" />
|
||||
<object-type name="DATASET_TRIGGER" enabled="true" />
|
||||
<object-type name="DATABASE_TRIGGER" enabled="true" />
|
||||
<object-type name="SYNONYM" enabled="true" />
|
||||
<object-type name="SEQUENCE" enabled="true" />
|
||||
<object-type name="PROCEDURE" enabled="true" />
|
||||
<object-type name="FUNCTION" enabled="true" />
|
||||
<object-type name="PACKAGE" enabled="true" />
|
||||
<object-type name="TYPE" enabled="true" />
|
||||
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
|
||||
<object-type name="ARGUMENT" enabled="true" />
|
||||
<object-type name="DIMENSION" enabled="true" />
|
||||
<object-type name="CLUSTER" enabled="true" />
|
||||
<object-type name="DBLINK" enabled="true" />
|
||||
</object-type-filter>
|
||||
</filters>
|
||||
<sorting>
|
||||
<object-type name="COLUMN" sorting-type="NAME" />
|
||||
<object-type name="FUNCTION" sorting-type="NAME" />
|
||||
<object-type name="PROCEDURE" sorting-type="NAME" />
|
||||
<object-type name="ARGUMENT" sorting-type="POSITION" />
|
||||
</sorting>
|
||||
<default-editors>
|
||||
<object-type name="VIEW" editor-type="SELECTION" />
|
||||
<object-type name="PACKAGE" editor-type="SELECTION" />
|
||||
<object-type name="TYPE" editor-type="SELECTION" />
|
||||
</default-editors>
|
||||
</browser-settings>
|
||||
<navigation-settings>
|
||||
<lookup-filters>
|
||||
<lookup-objects>
|
||||
<object-type name="SCHEMA" enabled="true" />
|
||||
<object-type name="USER" enabled="false" />
|
||||
<object-type name="ROLE" enabled="false" />
|
||||
<object-type name="PRIVILEGE" enabled="false" />
|
||||
<object-type name="CHARSET" enabled="false" />
|
||||
<object-type name="TABLE" enabled="true" />
|
||||
<object-type name="VIEW" enabled="true" />
|
||||
<object-type name="MATERIALIZED VIEW" enabled="true" />
|
||||
<object-type name="NESTED TABLE" enabled="false" />
|
||||
<object-type name="COLUMN" enabled="false" />
|
||||
<object-type name="INDEX" enabled="true" />
|
||||
<object-type name="CONSTRAINT" enabled="true" />
|
||||
<object-type name="DATASET TRIGGER" enabled="true" />
|
||||
<object-type name="DATABASE TRIGGER" enabled="true" />
|
||||
<object-type name="SYNONYM" enabled="false" />
|
||||
<object-type name="SEQUENCE" enabled="true" />
|
||||
<object-type name="PROCEDURE" enabled="true" />
|
||||
<object-type name="FUNCTION" enabled="true" />
|
||||
<object-type name="PACKAGE" enabled="true" />
|
||||
<object-type name="TYPE" enabled="true" />
|
||||
<object-type name="TYPE ATTRIBUTE" enabled="false" />
|
||||
<object-type name="ARGUMENT" enabled="false" />
|
||||
<object-type name="DIMENSION" enabled="false" />
|
||||
<object-type name="CLUSTER" enabled="false" />
|
||||
<object-type name="DBLINK" enabled="true" />
|
||||
</lookup-objects>
|
||||
<force-database-load value="false" />
|
||||
<prompt-connection-selection value="true" />
|
||||
<prompt-schema-selection value="true" />
|
||||
</lookup-filters>
|
||||
</navigation-settings>
|
||||
<dataset-grid-settings>
|
||||
<general>
|
||||
<enable-zooming value="true" />
|
||||
</general>
|
||||
<sorting>
|
||||
<nulls-first value="true" />
|
||||
<max-sorting-columns value="4" />
|
||||
</sorting>
|
||||
<tracking-columns>
|
||||
<columnNames value="" />
|
||||
<visible value="true" />
|
||||
<editable value="false" />
|
||||
</tracking-columns>
|
||||
</dataset-grid-settings>
|
||||
<dataset-editor-settings>
|
||||
<text-editor-popup>
|
||||
<active value="false" />
|
||||
<active-if-empty value="false" />
|
||||
<data-length-threshold value="100" />
|
||||
<popup-delay value="1000" />
|
||||
</text-editor-popup>
|
||||
<values-list-popup>
|
||||
<show-popup-button value="true" />
|
||||
<element-count-threshold value="1000" />
|
||||
<data-length-threshold value="250" />
|
||||
</values-list-popup>
|
||||
<general>
|
||||
<fetch-block-size value="100" />
|
||||
<fetch-timeout value="30" />
|
||||
<trim-whitespaces value="true" />
|
||||
<convert-empty-strings-to-null value="true" />
|
||||
<select-content-on-cell-edit value="true" />
|
||||
<large-value-preview-active value="true" />
|
||||
</general>
|
||||
<filters>
|
||||
<prompt-filter-dialog value="true" />
|
||||
<default-filter-type value="BASIC" />
|
||||
</filters>
|
||||
<qualified-text-editor text-length-threshold="300">
|
||||
<content-types>
|
||||
<content-type name="Text" enabled="true" />
|
||||
<content-type name="Properties" enabled="true" />
|
||||
<content-type name="XML" enabled="true" />
|
||||
<content-type name="DTD" enabled="true" />
|
||||
<content-type name="HTML" enabled="true" />
|
||||
<content-type name="XHTML" enabled="true" />
|
||||
<content-type name="Java" enabled="true" />
|
||||
<content-type name="SQL" enabled="true" />
|
||||
<content-type name="PL/SQL" enabled="true" />
|
||||
<content-type name="Groovy" enabled="true" />
|
||||
<content-type name="AIDL" enabled="true" />
|
||||
<content-type name="YAML" enabled="true" />
|
||||
<content-type name="Bash" enabled="true" />
|
||||
<content-type name="Manifest" enabled="true" />
|
||||
</content-types>
|
||||
</qualified-text-editor>
|
||||
<record-navigation>
|
||||
<navigation-target value="VIEWER" />
|
||||
</record-navigation>
|
||||
</dataset-editor-settings>
|
||||
<code-editor-settings>
|
||||
<general>
|
||||
<show-object-navigation-gutter value="false" />
|
||||
<show-spec-declaration-navigation-gutter value="true" />
|
||||
</general>
|
||||
<confirmations>
|
||||
<save-changes value="false" />
|
||||
<revert-changes value="true" />
|
||||
</confirmations>
|
||||
</code-editor-settings>
|
||||
<code-completion-settings>
|
||||
<filters>
|
||||
<basic-filter>
|
||||
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
||||
<filter-element type="OBJECT" id="schema" selected="true" />
|
||||
<filter-element type="OBJECT" id="role" selected="true" />
|
||||
<filter-element type="OBJECT" id="user" selected="true" />
|
||||
<filter-element type="OBJECT" id="privilege" selected="true" />
|
||||
<user-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="false" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</user-schema>
|
||||
<public-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="false" />
|
||||
<filter-element type="OBJECT" id="view" selected="false" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="false" />
|
||||
<filter-element type="OBJECT" id="index" selected="false" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="false" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="false" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="false" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="false" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="false" />
|
||||
<filter-element type="OBJECT" id="function" selected="false" />
|
||||
<filter-element type="OBJECT" id="package" selected="false" />
|
||||
<filter-element type="OBJECT" id="type" selected="false" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="false" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="false" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="false" />
|
||||
</public-schema>
|
||||
<any-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</any-schema>
|
||||
</basic-filter>
|
||||
<extended-filter>
|
||||
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
||||
<filter-element type="OBJECT" id="schema" selected="true" />
|
||||
<filter-element type="OBJECT" id="user" selected="true" />
|
||||
<filter-element type="OBJECT" id="role" selected="true" />
|
||||
<filter-element type="OBJECT" id="privilege" selected="true" />
|
||||
<user-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</user-schema>
|
||||
<public-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</public-schema>
|
||||
<any-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</any-schema>
|
||||
</extended-filter>
|
||||
</filters>
|
||||
<sorting enabled="true">
|
||||
<sorting-element type="RESERVED_WORD" id="keyword" />
|
||||
<sorting-element type="RESERVED_WORD" id="datatype" />
|
||||
<sorting-element type="OBJECT" id="column" />
|
||||
<sorting-element type="OBJECT" id="table" />
|
||||
<sorting-element type="OBJECT" id="view" />
|
||||
<sorting-element type="OBJECT" id="materialized view" />
|
||||
<sorting-element type="OBJECT" id="index" />
|
||||
<sorting-element type="OBJECT" id="constraint" />
|
||||
<sorting-element type="OBJECT" id="trigger" />
|
||||
<sorting-element type="OBJECT" id="synonym" />
|
||||
<sorting-element type="OBJECT" id="sequence" />
|
||||
<sorting-element type="OBJECT" id="procedure" />
|
||||
<sorting-element type="OBJECT" id="function" />
|
||||
<sorting-element type="OBJECT" id="package" />
|
||||
<sorting-element type="OBJECT" id="type" />
|
||||
<sorting-element type="OBJECT" id="dimension" />
|
||||
<sorting-element type="OBJECT" id="cluster" />
|
||||
<sorting-element type="OBJECT" id="dblink" />
|
||||
<sorting-element type="OBJECT" id="schema" />
|
||||
<sorting-element type="OBJECT" id="role" />
|
||||
<sorting-element type="OBJECT" id="user" />
|
||||
<sorting-element type="RESERVED_WORD" id="function" />
|
||||
<sorting-element type="RESERVED_WORD" id="parameter" />
|
||||
</sorting>
|
||||
<format>
|
||||
<enforce-code-style-case value="true" />
|
||||
</format>
|
||||
</code-completion-settings>
|
||||
<execution-engine-settings>
|
||||
<statement-execution>
|
||||
<fetch-block-size value="100" />
|
||||
<execution-timeout value="20" />
|
||||
<debug-execution-timeout value="600" />
|
||||
<focus-result value="false" />
|
||||
<prompt-execution value="false" />
|
||||
</statement-execution>
|
||||
<script-execution>
|
||||
<command-line-interfaces />
|
||||
<execution-timeout value="300" />
|
||||
</script-execution>
|
||||
<method-execution>
|
||||
<execution-timeout value="30" />
|
||||
<debug-execution-timeout value="600" />
|
||||
<parameter-history-size value="10" />
|
||||
</method-execution>
|
||||
</execution-engine-settings>
|
||||
<operation-settings>
|
||||
<transactions>
|
||||
<uncommitted-changes>
|
||||
<on-project-close value="ASK" />
|
||||
<on-disconnect value="ASK" />
|
||||
<on-autocommit-toggle value="ASK" />
|
||||
</uncommitted-changes>
|
||||
<multiple-uncommitted-changes>
|
||||
<on-commit value="ASK" />
|
||||
<on-rollback value="ASK" />
|
||||
</multiple-uncommitted-changes>
|
||||
</transactions>
|
||||
<session-browser>
|
||||
<disconnect-session value="ASK" />
|
||||
<kill-session value="ASK" />
|
||||
<reload-on-filter-change value="false" />
|
||||
</session-browser>
|
||||
<compiler>
|
||||
<compile-type value="KEEP" />
|
||||
<compile-dependencies value="ASK" />
|
||||
<always-show-controls value="false" />
|
||||
</compiler>
|
||||
<debugger>
|
||||
<debugger-type value="ASK" />
|
||||
<use-generic-runners value="true" />
|
||||
</debugger>
|
||||
</operation-settings>
|
||||
<ddl-file-settings>
|
||||
<extensions>
|
||||
<mapping file-type-id="VIEW" extensions="vw" />
|
||||
<mapping file-type-id="TRIGGER" extensions="trg" />
|
||||
<mapping file-type-id="PROCEDURE" extensions="prc" />
|
||||
<mapping file-type-id="FUNCTION" extensions="fnc" />
|
||||
<mapping file-type-id="PACKAGE" extensions="pkg" />
|
||||
<mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
|
||||
<mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
|
||||
<mapping file-type-id="TYPE" extensions="tpe" />
|
||||
<mapping file-type-id="TYPE_SPEC" extensions="tps" />
|
||||
<mapping file-type-id="TYPE_BODY" extensions="tpb" />
|
||||
</extensions>
|
||||
<general>
|
||||
<lookup-ddl-files value="true" />
|
||||
<create-ddl-files value="false" />
|
||||
<synchronize-ddl-files value="true" />
|
||||
<use-qualified-names value="false" />
|
||||
<make-scripts-rerunnable value="true" />
|
||||
</general>
|
||||
</ddl-file-settings>
|
||||
<general-settings>
|
||||
<regional-settings>
|
||||
<date-format value="MEDIUM" />
|
||||
<number-format value="UNGROUPED" />
|
||||
<locale value="SYSTEM_DEFAULT" />
|
||||
<use-custom-formats value="false" />
|
||||
</regional-settings>
|
||||
<environment>
|
||||
<environment-types>
|
||||
<environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" />
|
||||
<environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" />
|
||||
<environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" />
|
||||
<environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" />
|
||||
</environment-types>
|
||||
<visibility-settings>
|
||||
<connection-tabs value="true" />
|
||||
<dialog-headers value="true" />
|
||||
<object-editor-tabs value="true" />
|
||||
<script-editor-tabs value="false" />
|
||||
<execution-result-tabs value="true" />
|
||||
</visibility-settings>
|
||||
</environment>
|
||||
</general-settings>
|
||||
</component>
|
||||
<component name="DBNavigator.Project.StatementExecutionManager">
|
||||
<execution-variables />
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/libraries/Gradle___IOBoard_RPi_0_1_.xml
generated
Normal file
9
.idea/libraries/Gradle___IOBoard_RPi_0_1_.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: :IOBoard-RPi-0.1:">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/libs/IOBoard-RPi-0.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
11
.idea/libraries/Gradle__com_google_code_gson_gson_2_8_1.xml
generated
Normal file
11
.idea/libraries/Gradle__com_google_code_gson_gson_2_8_1.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: com.google.code.gson:gson:2.8.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.8.1/2a8e0aa38a2e21cb39e2f5a7d6704cbdc941da0/gson-2.8.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.8.1/c10732c97eccba635e20596a02c3824fef0605bf/gson-2.8.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
11
.idea/libraries/Gradle__org_postgresql_postgresql_42_1_1.xml
generated
Normal file
11
.idea/libraries/Gradle__org_postgresql_postgresql_42_1_1.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: org.postgresql:postgresql:42.1.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.postgresql/postgresql/42.1.1/8a0b76d763f5382d6357c412eeb14970ba4405f3/postgresql-42.1.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.postgresql/postgresql/42.1.1/bb754d9f75474fe97636543d0ff0d9f68bea930c/postgresql-42.1.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
5
.idea/modules/poc-java_main.iml
generated
5
.idea/modules/poc-java_main.iml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="poc-java:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="com.henrypump.poc" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/../../build/classes/main" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../../src/main">
|
||||
@@ -13,6 +13,9 @@
|
||||
<orderEntry type="library" name="Gradle: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.mongodb:mongodb-driver:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: de.vandermeer:asciitable:0.2.5" level="project" />
|
||||
<orderEntry type="library" name="Gradle: :IOBoard-RPi-0.1:" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.postgresql:postgresql:42.1.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.8.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.mongodb:bson:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.mongodb:mongodb-driver-core:3.4.2" level="project" />
|
||||
|
||||
5
.idea/modules/poc-java_test.iml
generated
5
.idea/modules/poc-java_test.iml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="poc-java:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="com.henrypump.poc" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output-test url="file://$MODULE_DIR$/../../build/classes/test" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../../src/test">
|
||||
@@ -14,6 +14,9 @@
|
||||
<orderEntry type="library" name="Gradle: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.mongodb:mongodb-driver:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: de.vandermeer:asciitable:0.2.5" level="project" />
|
||||
<orderEntry type="library" name="Gradle: :IOBoard-RPi-0.1:" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.postgresql:postgresql:42.1.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.8.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.mongodb:bson:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.mongodb:mongodb-driver-core:3.4.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: de.vandermeer:asciilist:0.0.3" level="project" />
|
||||
|
||||
959
.idea/workspace.xml
generated
959
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
FROM resin/rpi-raspbian:jessie
|
||||
# FROM ubuntu
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git-core \
|
||||
build-essential \
|
||||
gcc \
|
||||
oracle-java8-jdk\
|
||||
curl\
|
||||
wget\
|
||||
--no-install-recommends && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN git clone git://git.drogon.net/wiringPi
|
||||
RUN cd wiringPi && ./build
|
||||
RUN curl -s get.pi4j.com | bash
|
||||
COPY build/libs/poc-java-all-1.0-SNAPSHOT.jar /root
|
||||
COPY rpi_startup.sh /root
|
||||
|
||||
# Define working directory
|
||||
WORKDIR /data
|
||||
VOLUME /data
|
||||
|
||||
CMD ["/root/rpi_startup.sh"]
|
||||
@@ -13,6 +13,10 @@ targetCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
maven { url "http://repo.maven.apache.org/maven2" }
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -20,6 +24,9 @@ dependencies {
|
||||
compile group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1.1'
|
||||
compile group: 'org.mongodb', name: 'mongodb-driver', version:'3.4.2'
|
||||
compile group: 'de.vandermeer', name: 'asciitable', version:'0.2.5'
|
||||
compile name: 'IOBoard-RPi-0.1'
|
||||
compile group: 'org.postgresql', name: 'postgresql', version: '42.1.1'
|
||||
compile 'com.google.code.gson:gson:2.8.1'
|
||||
testCompile group: 'junit', name: 'junit', version:'3.8.1'
|
||||
}
|
||||
|
||||
|
||||
92
db_setup.sql
Normal file
92
db_setup.sql
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cards(
|
||||
id SERIAL PRIMARY KEY,
|
||||
stroke_number INTEGER unique,
|
||||
surface_position INTEGER ARRAY,
|
||||
surface_load INTEGER ARRAY,
|
||||
downhole_position INTEGER ARRAY,
|
||||
downhole_load INTEGER ARRAY,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS measurement_configs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
m_name TEXT UNIQUE NOT NULL,
|
||||
units TEXT,
|
||||
store_delta REAL NOT NULL,
|
||||
store_time REAL NOT NULL,
|
||||
use_total BOOLEAN NOT NULL,
|
||||
use_average BOOLEAN NOT NULL,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS measurements_num (
|
||||
id SERIAL PRIMARY KEY,
|
||||
m_id INTEGER references measurement_configs(id),
|
||||
val REAL NOT NULL,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS measurements_text (
|
||||
id SERIAL PRIMARY KEY,
|
||||
m_id INTEGER references measurement_configs(id),
|
||||
val TEXT NOT NULL,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS daily_totals (
|
||||
id SERIAL PRIMARY KEY,
|
||||
m_id INTEGER references measurement_configs(id),
|
||||
current_value REAL NOT NULL,
|
||||
max_value REAL NOT NULL,
|
||||
min_value REAL NOT NULL,
|
||||
average_value REAL,
|
||||
total_value REAL,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS well_tests (
|
||||
id SERIAL PRIMARY KEY,
|
||||
test_completed_timestamp TIMESTAMP NOT NULL,
|
||||
test_hours REAL NOT NULL,
|
||||
total_bbl REAL NOT NULL,
|
||||
oil_bbl REAL,
|
||||
h2o_bbl REAL,
|
||||
gas_mcf REAL,
|
||||
k_factor REAL,
|
||||
oil_bbl_ratio REAL,
|
||||
h2o_bbl_ratio REAL,
|
||||
gas_mcf_ratio REAL,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fluid_shots (
|
||||
id SERIAL PRIMARY KEY,
|
||||
shot_timestamp TIMESTAMP,
|
||||
pump_intake_pressure REAL NOT NULL,
|
||||
fluid_level REAL NOT NULL,
|
||||
friction_estimate REAL NOT NULL,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS device_statuses (
|
||||
id SERIAL PRIMARY KEY,
|
||||
status TEXT NOT NULL,
|
||||
initiator TEXT,
|
||||
status_timestamp TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS well_configs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
taper_setup JSON NOT NULL,
|
||||
well_config JSON NOT NULL,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS setpoints (
|
||||
id SERIAL PRIMARY KEY,
|
||||
param TEXT UNIQUE NOT NULL,
|
||||
setpoint_value REAL NOT NULL,
|
||||
ts_added TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
BIN
libs/IOBoard-0.1.jar
Normal file
BIN
libs/IOBoard-0.1.jar
Normal file
Binary file not shown.
BIN
libs/IOBoard-RPi-0.1.jar
Normal file
BIN
libs/IOBoard-RPi-0.1.jar
Normal file
Binary file not shown.
1
rpi_startup.sh
Normal file
1
rpi_startup.sh
Normal file
@@ -0,0 +1 @@
|
||||
java -classpath .:classes:/opt/pi4j/lib/'*':/root/poc-java-all-1.0-SNAPSHOT.jar com.henrypump.poc.POC localhost
|
||||
@@ -10,6 +10,7 @@ import mraa.mraa;
|
||||
import mraa.Platform;
|
||||
import mraa.Result;
|
||||
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
|
||||
@@ -23,6 +24,7 @@ public class AnalogIn {
|
||||
private double euMax;
|
||||
private double[] history = new double[100];
|
||||
|
||||
|
||||
AnalogIn(int channel, double rawMin, double rawMax, double euMin, double euMax){
|
||||
this.channel = channel;
|
||||
if (channel != 99) {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@@ -4,333 +4,532 @@ package com.henrypump.poc;
|
||||
* Created by patrickjmcd on 2/2/17.
|
||||
*/
|
||||
|
||||
import com.mongodb.*;
|
||||
|
||||
import com.mongodb.client.AggregateIterable;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.model.*;
|
||||
|
||||
import org.bson.BSON;
|
||||
import com.google.gson.*;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.postgresql.util.PGobject;
|
||||
|
||||
import com.mongodb.client.MongoCursor;
|
||||
import static com.mongodb.client.model.Filters.*;
|
||||
|
||||
import javax.print.Doc;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
public class Database {
|
||||
private String pocDatabase = "poc";
|
||||
private MongoClient mongoClient;
|
||||
private MongoDatabase database;
|
||||
private MongoCollection<Document> cardCollection, wellDataCollection, gaugeOffCollection, wellTestCollection,
|
||||
fluidShotsCollection, runStatusCollection, wellConfigCollection, setpointCollection;
|
||||
|
||||
public void initCollections(){
|
||||
cardCollection = database.getCollection("cards");
|
||||
cardCollection.createIndex(Indexes.ascending("timestamp", "strokeNumber"));
|
||||
|
||||
wellDataCollection = database.getCollection("wellData");
|
||||
wellDataCollection.createIndex(Indexes.ascending("timestamp", "tagName"));
|
||||
|
||||
gaugeOffCollection = database.getCollection("gaugeOff");
|
||||
gaugeOffCollection.createIndex(Indexes.ascending("timestamp", "tagName"));
|
||||
public class Database{
|
||||
String dbHost = "localhost";
|
||||
String dbName = "poc";
|
||||
Connection dbConn;
|
||||
|
||||
|
||||
wellTestCollection = database.getCollection("wellTests");
|
||||
wellTestCollection.createIndex(Indexes.ascending("testStartTime"));
|
||||
|
||||
fluidShotsCollection = database.getCollection("fluidShots");
|
||||
fluidShotsCollection.createIndex(Indexes.ascending("timestamp"));
|
||||
|
||||
runStatusCollection = database.getCollection("runStatus");
|
||||
runStatusCollection.createIndex(Indexes.ascending("timestamp"));
|
||||
|
||||
wellConfigCollection = database.getCollection("wellConfiguration");
|
||||
wellConfigCollection.createIndex(Indexes.ascending("timestamp"));
|
||||
|
||||
setpointCollection = database.getCollection("setpoints");
|
||||
setpointCollection.createIndex(Indexes.ascending("name"));
|
||||
private Connection connectToDatabase() {
|
||||
Connection conn = null;
|
||||
try
|
||||
{
|
||||
Class.forName("org.postgresql.Driver");
|
||||
String url = "jdbc:postgresql://" + dbHost + "/"+ dbName;
|
||||
Properties props = new Properties();
|
||||
props.setProperty("user","poc");
|
||||
props.setProperty("password","poc");
|
||||
conn = DriverManager.getConnection(url, props);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.exit(2);
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
||||
Database(){
|
||||
mongoClient = new MongoClient();
|
||||
database = mongoClient.getDatabase(pocDatabase);
|
||||
|
||||
initCollections();
|
||||
|
||||
|
||||
dbConn = connectToDatabase();
|
||||
}
|
||||
|
||||
Database(String dbHostname){
|
||||
mongoClient = new MongoClient(dbHostname);
|
||||
database = mongoClient.getDatabase(pocDatabase);
|
||||
|
||||
initCollections();
|
||||
dbHost = dbHostname;
|
||||
dbConn = connectToDatabase();
|
||||
}
|
||||
|
||||
public void close(){
|
||||
mongoClient.close();
|
||||
static Object[] makeObjectArray(double[] doubleArray) {
|
||||
Object[] objList = new Object[doubleArray.length];
|
||||
for (int i = 0; i < doubleArray.length; i++){
|
||||
objList[i] = (Object) doubleArray[i];
|
||||
}
|
||||
return objList;
|
||||
}
|
||||
|
||||
//CARD FUNCTIONS
|
||||
|
||||
public long getLastStrokeNum(){
|
||||
|
||||
long lastStroke = 0;
|
||||
|
||||
MongoCollection<Document> collection = database.getCollection("cards");
|
||||
MongoCursor<Document> cursor = collection.aggregate(
|
||||
Arrays.asList(
|
||||
Aggregates.group("strokeNumber", Accumulators.last("lastStroke", "$strokeNumber"))
|
||||
)
|
||||
).iterator();
|
||||
|
||||
long lastStroke = -1;
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
long docStroke = cursor.next().getLong("lastStroke");
|
||||
if (docStroke > lastStroke) { lastStroke = docStroke; }
|
||||
String selString = "SELECT MAX(id) numCards FROM cards";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
lastStroke = rs.getInt("numCards");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Found last stroke to be " + lastStroke);
|
||||
return lastStroke;
|
||||
}
|
||||
|
||||
public long newCard(Card inpCard){
|
||||
|
||||
List<Double> s_p = new ArrayList<Double>();
|
||||
List<Double> s_l = new ArrayList<Double>();
|
||||
List<Double> d_p = new ArrayList<Double>();
|
||||
List<Double> d_l = new ArrayList<Double>();
|
||||
int numPointsScan = inpCard.getNumPointsUsed();
|
||||
double[] sp = inpCard.getSurfacePosition();
|
||||
double[] sl = inpCard.getSurfaceLoad();
|
||||
double[] dp = inpCard.getDownholePosition();
|
||||
double[] dl = inpCard.getDownholeLoad();
|
||||
for(int i = 0; i < numPointsScan; i++ ) {
|
||||
s_p.add(sp[i]);
|
||||
s_l.add(sl[i]);
|
||||
d_p.add(dp[i]);
|
||||
d_l.add(dl[i]);
|
||||
}
|
||||
|
||||
Document doc = new Document("strokeNumber", inpCard.getStrokeNumber())
|
||||
.append("surface_position", s_p)
|
||||
.append("surface_load", s_l)
|
||||
.append("downhole_position", d_p)
|
||||
.append("downhole_load", d_l)
|
||||
.append("timestamp", Date.from(ZonedDateTime.now().toInstant()));
|
||||
cardCollection.insertOne(doc);
|
||||
System.out.println("Stored stroke number " + inpCard.getStrokeNumber() + " as " + doc.getObjectId("_id"));
|
||||
return cardCollection.count();
|
||||
}
|
||||
|
||||
|
||||
public long newMeasurement(Measurement inpMeasurement){
|
||||
Document doc = new Document("tagname", inpMeasurement.getTagName())
|
||||
.append("currentValue", inpMeasurement.getCurrentValue())
|
||||
.append("maxDailyValue", inpMeasurement.getDailyMax())
|
||||
.append("minDailyValue", inpMeasurement.getDailyMin())
|
||||
.append("dailyAverage", inpMeasurement.getAverage())
|
||||
.append("dailyTotal", inpMeasurement.getTotal())
|
||||
.append("numMeasurements", inpMeasurement.getNumMeasurements())
|
||||
.append("timestamp", Date.from(ZonedDateTime.now().toInstant()));
|
||||
wellDataCollection.insertOne(doc);
|
||||
System.out.println("Stored " + inpMeasurement.getCurrentValue() + " for " + inpMeasurement.getTagName());
|
||||
return wellDataCollection.count();
|
||||
}
|
||||
|
||||
public Document getLastStoredMeasurement(String tagName){
|
||||
MongoCursor<Document> cursor = wellDataCollection.find(eq("tagname", tagName)).sort(Sorts.descending("timestamp")).limit(1).iterator();
|
||||
Document lastStoredDoc = new Document();
|
||||
String sqlInsert = "INSERT INTO cards (stroke_number, surface_position, surface_load, downhole_position, downhole_load) VALUES (?, ?, ?, ?, ?)";
|
||||
long numCards = -1;
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastStoredDoc = cursor.next();
|
||||
Array surf_pos = dbConn.createArrayOf("float4", makeObjectArray(inpCard.getSurfacePosition()));
|
||||
Array surf_lod = dbConn.createArrayOf("float4", makeObjectArray(inpCard.getSurfaceLoad()));
|
||||
Array down_pos = dbConn.createArrayOf("float4", makeObjectArray(inpCard.getDownholePosition()));
|
||||
Array down_lod = dbConn.createArrayOf("float4", makeObjectArray(inpCard.getDownholeLoad()));
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
prepInsert.setLong(1, inpCard.getStrokeNumber());
|
||||
prepInsert.setArray(2, surf_pos);
|
||||
prepInsert.setArray(3, surf_lod);
|
||||
prepInsert.setArray(4, down_pos);
|
||||
prepInsert.setArray(5, down_lod);
|
||||
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT COUNT(id) numCards FROM cards";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
numCards = rs.getLong("numCards");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return lastStoredDoc;
|
||||
return numCards;
|
||||
}
|
||||
|
||||
// MEASUREMENT FUNCTIONS
|
||||
public long tryNewMeasurementConfig(Measurement inpMeasurement){
|
||||
String sqlSelect = "SELECT id FROM measurement_configs WHERE m_name = ?";
|
||||
long dbId = -1;
|
||||
try {
|
||||
PreparedStatement ps = dbConn.prepareStatement(sqlSelect);
|
||||
ps.setString(1, inpMeasurement.getTagName());
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
dbId = rs.getInt("id");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//If measurement already exists
|
||||
if (dbId == -1){
|
||||
String sqlInsert = "INSERT INTO measurement_configs (m_name, units, store_delta, store_time, use_total, use_average) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?)";
|
||||
try {
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
prepInsert.setString(1, inpMeasurement.getTagName());
|
||||
prepInsert.setString(2, inpMeasurement.getUnits());
|
||||
prepInsert.setDouble(3, inpMeasurement.getSendDelta());
|
||||
prepInsert.setDouble(4, inpMeasurement.getSendTimeDelta());
|
||||
prepInsert.setBoolean(5, inpMeasurement.isUseTotal());
|
||||
prepInsert.setBoolean(6, inpMeasurement.isUseAverage());
|
||||
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT id FROM measurement_configs WHERE m_name = ?";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ps.setString(1, inpMeasurement.getTagName());
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
dbId = rs.getLong("id");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
return dbId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public long newMeasurementValue(Measurement inpMeasurement){
|
||||
String sqlInsert = "INSERT INTO measurements_num (m_id, val) VALUES (?, ?)";
|
||||
long numMeasurements = -1;
|
||||
try {
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
prepInsert.setLong(1, inpMeasurement.getDbId());
|
||||
prepInsert.setDouble(2, inpMeasurement.getCurrentValue());
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT COUNT(id) numMeasurements FROM measurements_num";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
numMeasurements = rs.getLong("numMeasurements");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return numMeasurements;
|
||||
}
|
||||
|
||||
public double getLastStoredMeasurement(long dbId){
|
||||
String sqlSelect = "SELECT val FROM measurements_num WHERE id = (SELECT MAX(id) FROM measurements_num WHERE m_id = ?)";
|
||||
//TODO: Add query to find current average, number of measurements, total, max, and min for today.
|
||||
|
||||
double retValue = Double.MIN_VALUE;
|
||||
try {
|
||||
PreparedStatement ps = dbConn.prepareStatement(sqlSelect);
|
||||
ps.setLong(1, dbId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
retValue = rs.getInt("val");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
public long newDailyTotal(Measurement inpMeasurement){
|
||||
Document doc = new Document("tagname", inpMeasurement.getTagName())
|
||||
.append("currentValue", inpMeasurement.getCurrentValue())
|
||||
.append("maxDailyValue", inpMeasurement.getDailyMax())
|
||||
.append("minDailyValue", inpMeasurement.getDailyMin())
|
||||
.append("dailyAverage", inpMeasurement.getAverage())
|
||||
.append("dailyTotal", inpMeasurement.getTotal())
|
||||
.append("timestamp", Date.from(ZonedDateTime.now().toInstant()));
|
||||
gaugeOffCollection.insertOne(doc);
|
||||
return gaugeOffCollection.count();
|
||||
String sqlInsert = "INSERT INTO daily_totals (m_id, current_value, max_value, min_value, average_value, total_value) VALUES (?, ?, ?, ?, ?, ?)";
|
||||
|
||||
|
||||
long numMeasurements = -1;
|
||||
try {
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
prepInsert.setLong(1, inpMeasurement.getDbId());
|
||||
prepInsert.setDouble(2, inpMeasurement.getCurrentValue());
|
||||
prepInsert.setDouble(3, inpMeasurement.getDailyMax());
|
||||
prepInsert.setDouble(4, inpMeasurement.getDailyMin());
|
||||
prepInsert.setDouble(5, inpMeasurement.getAverage());
|
||||
prepInsert.setDouble(6, inpMeasurement.getTotal());
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT COUNT(id) numMeasurements FROM daily_totals";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
numMeasurements = rs.getLong("numMeasurements");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return numMeasurements;
|
||||
|
||||
}
|
||||
|
||||
public double getPreviousDailyTotal(ZonedDateTime inpDateTime){
|
||||
String isoInpDateTime = inpDateTime.toString();
|
||||
MongoCursor<Document> cursor = wellTestCollection.find(and(eq("tagname", "Fluid Produced"), lte("timestamp", isoInpDateTime)))
|
||||
.sort(Sorts.descending("timestamp")).limit(1).iterator();
|
||||
double lastTotal = -1.0;
|
||||
String sqlSelect = "SELECT total_value FROM daily_totals WHERE id = (SELECT MAX(id) FROM daily_totals WHERE m_id = " +
|
||||
"(SELECT m_id FROM well_configs WHERE m_name = 'Fluid Produced'))";
|
||||
double lastTotal = -1;
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastTotal = cursor.next().getDouble("dailyTotal");
|
||||
PreparedStatement ps = dbConn.prepareStatement(sqlSelect);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
lastTotal = rs.getInt("total_value");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return lastTotal;
|
||||
};
|
||||
|
||||
public long newWellTest(WellTest inp){
|
||||
Document doc = new Document("testStartTime", Date.from(inp.getTestStart().toInstant()))
|
||||
.append("testHours", inp.getTestHours())
|
||||
.append("testTotalBBL", inp.getTotalFluidBBL())
|
||||
.append("testOilBBL", inp.getTestOilBBL())
|
||||
.append("testWaterBBL", inp.getTestWaterBBL())
|
||||
.append("testGasMCF", inp.getTestGasMCF())
|
||||
.append("kFactor", inp.getkFactor())
|
||||
.append("oilRatio", inp.getOilRatio())
|
||||
.append("waterRatio", inp.getWaterRatio())
|
||||
.append("gasMCFRatio", inp.getGasMCFRatio());
|
||||
wellTestCollection.insertOne(doc);
|
||||
return wellTestCollection.count();
|
||||
}
|
||||
|
||||
public Document getPreviousWellTest(ZonedDateTime inpDateTime){
|
||||
MongoCursor<Document> cursor = wellTestCollection.find(lte("testStartTime", Date.from(inpDateTime.toInstant())))
|
||||
.sort(Sorts.descending("testStartTime")).limit(1).iterator();
|
||||
Document lastTest = new Document("kFactor", (Double) 1.0);
|
||||
public long newWellTest(WellTest inp){
|
||||
String sqlInsert = "INSERT INTO well_tests (test_completed_timestamp, test_hours, total_bbl, oil_bbl, h2o_bbl, gas_mcf," +
|
||||
" k_factor, oil_bbl_ratio, h2o_bbl_ratio, gas_mcf_ratio) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
long numTests = -1;
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastTest = cursor.next();
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
prepInsert.setTimestamp(1, new Timestamp(Date.from(inp.getTestStart().toInstant()).getTime()));
|
||||
prepInsert.setDouble(2, inp.getTestHours());
|
||||
prepInsert.setDouble(3, inp.getTotalFluidBBL());
|
||||
prepInsert.setDouble(4, inp.getTestOilBBL());
|
||||
prepInsert.setDouble(5, inp.getTestWaterBBL());
|
||||
prepInsert.setDouble(6, inp.getTestGasMCF());
|
||||
prepInsert.setDouble(7, inp.getkFactor());
|
||||
prepInsert.setDouble(8, inp.getOilRatio());
|
||||
prepInsert.setDouble(9, inp.getWaterRatio());
|
||||
prepInsert.setDouble(10, inp.getGasMCFRatio());
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT COUNT(id) numTests FROM well_tests";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
numTests = rs.getLong("numTests");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return lastTest;
|
||||
return numTests;
|
||||
}
|
||||
|
||||
public WellTest getPreviousWellTest(ZonedDateTime inpDateTime){
|
||||
String selectSql = "SELECT * FROM well_tests WHERE test_completed_timestamp <= ? ORDER BY test_completed_timestamp DESC LIMIT 1";
|
||||
WellTest wt = null;
|
||||
try {
|
||||
PreparedStatement ps = dbConn.prepareStatement(selectSql);
|
||||
ps.setTimestamp(1, new Timestamp(Date.from(inpDateTime.toInstant()).getTime()));
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
wt = new WellTest(rs.getTimestamp("test_completed_timestamp").toInstant().atZone(ZoneId.of("GMT")), rs.getDouble("test_hours"),
|
||||
rs.getDouble("total_bbl"), rs.getDouble("oil_bbl"), rs.getDouble("h20_bbl"),
|
||||
rs.getDouble("gas_mcf"), rs.getDouble("k_factor"));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return wt;
|
||||
};
|
||||
|
||||
public double getLatestKFactor(){
|
||||
MongoCursor<Document> cursor = wellTestCollection.find().sort(Sorts.descending("testStartTime")).limit(1).iterator();
|
||||
String selectSql = "SELECT k_factor from well_tests WHERE id = (SELECT MAX(id) FROM well_tests)";
|
||||
double kFactor = 1.0;
|
||||
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
kFactor = cursor.next().getDouble("kFactor");
|
||||
PreparedStatement ps = dbConn.prepareStatement(selectSql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
kFactor = rs.getDouble("k_factor");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return kFactor;
|
||||
}
|
||||
|
||||
public long newFluidShot(FluidShot inp){
|
||||
String df = ZonedDateTime.now().toString();
|
||||
Document doc = new Document("timestamp", Date.from(ZonedDateTime.now().toInstant()))
|
||||
.append("fluidLevel", inp.getFluidLevel())
|
||||
.append("pumpIntakePressure", inp.getPumpIntakePressure())
|
||||
.append("frictionEstimate", inp.getFrictionEstimate());
|
||||
fluidShotsCollection.insertOne(doc);
|
||||
return fluidShotsCollection.count();
|
||||
String sqlInsert = "INSERT INTO fluid_shots (shot_timestamp, fluid_level, pump_intake_pressure, friction_estimate) VALUES (?, ?, ?, ?)";
|
||||
Timestamp ts = new Timestamp(Date.from(ZonedDateTime.now().toInstant()).getTime());
|
||||
long numShots = -1;
|
||||
try {
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
prepInsert.setTimestamp(1, ts);
|
||||
prepInsert.setDouble(2, inp.getFluidLevel());
|
||||
prepInsert.setDouble(3, inp.getPumpIntakePressure());
|
||||
prepInsert.setDouble(4, inp.getFrictionEstimate());
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT COUNT(id) numShots FROM fluid_shots";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
numShots = rs.getLong("numShots");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return numShots;
|
||||
}
|
||||
|
||||
public double getLatestFrictionEstimate(){
|
||||
MongoCursor<Document> cursor = fluidShotsCollection.find().sort(Sorts.descending("timestamp")).limit(1).iterator();
|
||||
double frictionEstimate = -1;
|
||||
String selectSql = "SELECT friction_estimate from fluid_shots WHERE id = (SELECT MAX(id) FROM fluid_shots)";
|
||||
double frictionEstimate = 1.0;
|
||||
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
frictionEstimate = cursor.next().getDouble("frictionEstimate");
|
||||
PreparedStatement ps = dbConn.prepareStatement(selectSql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
frictionEstimate = rs.getDouble("friction_estimate");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return frictionEstimate;
|
||||
}
|
||||
|
||||
public long newRunStatus(String runStatus, String initiator){
|
||||
Document doc = new Document("status", runStatus)
|
||||
.append("initiator", initiator)
|
||||
.append("timestamp", Date.from(ZonedDateTime.now().toInstant()));
|
||||
runStatusCollection.insertOne(doc);
|
||||
return runStatusCollection.count();
|
||||
String sqlInsert = "INSERT INTO device_statuses (status, initiator) VALUES (?, ?)";
|
||||
|
||||
long numStatuses = -1;
|
||||
try {
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
prepInsert.setString(1, runStatus);
|
||||
prepInsert.setString(2, initiator);
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT COUNT(id) numStatuses FROM device_statuses";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
numStatuses = rs.getLong("numStatuses");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return numStatuses;
|
||||
}
|
||||
|
||||
public long storeWellSetup(Well thisWell){
|
||||
ArrayList<Document> taperArr = new ArrayList<Document>();
|
||||
Gson gson = new Gson();
|
||||
JsonObject wellConfig = new JsonObject();
|
||||
JsonArray taperArr = new JsonArray();
|
||||
|
||||
PGobject wellConfigObj = new PGobject();
|
||||
wellConfigObj.setType("json");
|
||||
|
||||
PGobject taperArrayObj = new PGobject();
|
||||
taperArrayObj.setType("json");
|
||||
|
||||
for (int i = 1; i <= thisWell.getNumTapers(); i++){
|
||||
Document tap = new Document("length", thisWell.getRodLength(i))
|
||||
.append("diameter", thisWell.getRodDiameter(i))
|
||||
.append("material", thisWell.getRodMaterial(i))
|
||||
.append("dampingFactor", thisWell.getDampingFactor(i));
|
||||
JsonObject tap = new JsonObject();
|
||||
tap.add("length", new JsonPrimitive(thisWell.getRodLength(i)));
|
||||
tap.add("diameter", new JsonPrimitive(thisWell.getRodDiameter(i)));
|
||||
tap.add("material", new JsonPrimitive(thisWell.getRodMaterial(i)));
|
||||
tap.add("dampingFactor", new JsonPrimitive(thisWell.getDampingFactor(i)));
|
||||
taperArr.add(tap);
|
||||
}
|
||||
wellConfig.add("wellName", new JsonPrimitive(thisWell.getWellName()));
|
||||
wellConfig.add("deltaT", new JsonPrimitive(thisWell.getDt()));
|
||||
wellConfig.add("pumpDiameter", new JsonPrimitive(thisWell.getPumpDiameter()));
|
||||
wellConfig.add("fluidGradient", new JsonPrimitive(thisWell.getFluidGradient()));
|
||||
wellConfig.add("tubingID", new JsonPrimitive(thisWell.getTubingID()));
|
||||
wellConfig.add("tubingOD", new JsonPrimitive(thisWell.getTubingOD()));
|
||||
wellConfig.add("tubingAnchorDepth", new JsonPrimitive(thisWell.getTubingAnchorDepth()));
|
||||
wellConfig.add("structuralRating", new JsonPrimitive(thisWell.getStructuralRating()));
|
||||
wellConfig.add("stuffingBoxFriction", new JsonPrimitive(thisWell.getSbfriction()));
|
||||
wellConfig.add("tubingHeadPressure", new JsonPrimitive(thisWell.getTubingHeadPressure()));
|
||||
wellConfig.add("tapers", taperArr);
|
||||
wellConfig.add("storedBy", new JsonPrimitive("poc"));
|
||||
|
||||
|
||||
Document doc = new Document("timestamp", Date.from(ZonedDateTime.now().toInstant()))
|
||||
.append("wellName", thisWell.getWellName())
|
||||
.append("deltaT", thisWell.getDt())
|
||||
.append("pumpDiameter", thisWell.getPumpDiameter())
|
||||
.append("fluidGradient", thisWell.getFluidGradient())
|
||||
.append("tubingID", thisWell.getTubingID())
|
||||
.append("tubingOD", thisWell.getTubingOD())
|
||||
.append("tubingAnchorDepth", thisWell.getTubingAnchorDepth())
|
||||
.append("structuralRating", thisWell.getStructuralRating())
|
||||
.append("stuffingBoxFriction", thisWell.getSbfriction())
|
||||
.append("tubingHeadPressure", thisWell.getTubingHeadPressure())
|
||||
.append("tapers", taperArr)
|
||||
.append("storedBy", "poc");
|
||||
String sqlInsert = "INSERT INTO well_configs (taper_setup, well_config) VALUES (?, ?)";
|
||||
long numConfigs = -1;
|
||||
try {
|
||||
|
||||
wellConfigCollection.insertOne(doc);
|
||||
return wellConfigCollection.count();
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
|
||||
taperArrayObj.setValue(gson.toJson(taperArr));
|
||||
prepInsert.setObject(1, taperArrayObj);
|
||||
|
||||
wellConfigObj.setValue(gson.toJson(wellConfig));
|
||||
prepInsert.setObject(2, wellConfigObj);
|
||||
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT COUNT(id) numConfigs FROM well_configs";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
numConfigs = rs.getLong("numConfigs");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return numConfigs;
|
||||
}
|
||||
|
||||
public Document getLatestWellConfiguration(){
|
||||
MongoCursor<Document> cursor = wellConfigCollection.find().sort(Sorts.descending("timestamp")).limit(1).iterator();
|
||||
Document lastConfig = new Document();
|
||||
public JsonObject getLatestWellConfiguration(){
|
||||
Gson gson = new Gson();
|
||||
String selectSql = "SELECT * from well_configs WHERE id = (SELECT MAX(id) FROM well_configs)";
|
||||
JsonObject config = new JsonObject();
|
||||
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastConfig = cursor.next();
|
||||
PreparedStatement ps = dbConn.prepareStatement(selectSql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
config.add("tapers", new JsonPrimitive(rs.getString("taper_setup")));
|
||||
config.add("well_config", new JsonPrimitive(rs.getString("well_config")));
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return lastConfig;
|
||||
return config;
|
||||
}
|
||||
|
||||
public long storeSetpoint(String setpointName, double setpointValue){
|
||||
Document newSetpoint = new Document("name", setpointName)
|
||||
.append("value", setpointValue)
|
||||
.append("lastStored", Date.from(ZonedDateTime.now().toInstant()))
|
||||
.append("storedBy", "poc");
|
||||
setpointCollection.updateOne(eq("name", setpointName), new Document("$set", newSetpoint), (new UpdateOptions()).upsert(true));
|
||||
return setpointCollection.count();
|
||||
String sqlInsert = "INSERT INTO setpoints (param, setpoint_value) VALUES (?, ?) ON CONFLICT DO UPDATE setpoints SET setpoint_value = ? WHERE param = ?";
|
||||
long numSetpoints = -1;
|
||||
try {
|
||||
PreparedStatement prepInsert = dbConn.prepareStatement(sqlInsert);
|
||||
prepInsert.setString(1, setpointName);
|
||||
prepInsert.setDouble(2, setpointValue);
|
||||
prepInsert.setDouble(3, setpointValue);
|
||||
prepInsert.setString(4, setpointName);
|
||||
prepInsert.executeUpdate();
|
||||
|
||||
String selString = "SELECT COUNT(id) numSetpoints FROM well_configs";
|
||||
PreparedStatement ps = dbConn.prepareStatement(selString);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
numSetpoints = rs.getLong("numSetpoints");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return numSetpoints;
|
||||
}
|
||||
|
||||
public Double getSetpoint(String setpointName){
|
||||
Document setpointDoc = setpointCollection.find(eq("name", setpointName)).first();
|
||||
double setpoint;
|
||||
String sqlSelect = "SELECT setpoint_value FROM setpoints WHERE param = ?";
|
||||
double setpoint = -1;
|
||||
|
||||
try {
|
||||
setpoint = setpointDoc.getDouble("value");
|
||||
String storedBy = setpointDoc.getString("storedBy");
|
||||
System.out.println("Setpoint retrieved from database: [" + setpointName + " = " + setpoint + " stored by " + storedBy + "]");
|
||||
} catch (ClassCastException e){
|
||||
setpoint = Double.parseDouble(setpointDoc.get("value").toString());
|
||||
String storedBy = setpointDoc.getString("storedBy");
|
||||
System.out.println("Setpoint retrieved from database: [" + setpointName + " = " + setpoint + " stored by " + storedBy + "]");
|
||||
} catch (NullPointerException e){
|
||||
setpoint = Double.MIN_VALUE;
|
||||
System.out.println("Could not find a value for " + setpointName + " in the database.");
|
||||
PreparedStatement ps = dbConn.prepareStatement(sqlSelect);
|
||||
ps.setString(1, setpointName);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()){
|
||||
setpoint = rs.getDouble("setpoint_value");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
} catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return setpoint;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
import com.henrypump.rpio.DigitalIn;
|
||||
import com.henrypump.rpio.DigitalOut;
|
||||
import com.henrypump.rpio.MuxSetup;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 2/10/17.
|
||||
*/
|
||||
@@ -15,14 +19,14 @@ public class IOControl implements Runnable {
|
||||
IOControl(POC poc){
|
||||
this.poc = poc;
|
||||
// IO
|
||||
startBtn = new DigitalIn(99);
|
||||
stopBtn = new DigitalIn(99);
|
||||
led2 = new DigitalOut(2, 0);
|
||||
led3 = new DigitalOut(3, 0);
|
||||
led4 = new DigitalOut(4, 0);
|
||||
led5 = new DigitalOut(5, 0);
|
||||
runningIndicator = new DigitalOut(6,0);
|
||||
runCommand = new DigitalOut(7,0);
|
||||
startBtn = new DigitalIn(1);
|
||||
stopBtn = new DigitalIn(2);
|
||||
led2 = new DigitalOut(3);
|
||||
led3 = new DigitalOut(4);
|
||||
led4 = new DigitalOut(5);
|
||||
led5 = new DigitalOut(6);
|
||||
runningIndicator = new DigitalOut(2);
|
||||
runCommand = new DigitalOut(1);
|
||||
}
|
||||
|
||||
private void startWell(){
|
||||
@@ -40,20 +44,20 @@ public class IOControl implements Runnable {
|
||||
}
|
||||
|
||||
public void allOutputsOff(){
|
||||
led2.write(0,true);
|
||||
led3.write(0,true);
|
||||
led4.write(0,true);
|
||||
led5.write(0,true);
|
||||
runningIndicator.write(0, true);
|
||||
runCommand.write(0,true);
|
||||
led2.write(0);
|
||||
led3.write(0);
|
||||
led4.write(0);
|
||||
led5.write(0);
|
||||
runningIndicator.write(0);
|
||||
runCommand.write(0);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
System.out.println("Running the IOControl Loop");
|
||||
for (;;) {
|
||||
if (startBtn.read() == 1) startWell();
|
||||
if (stopBtn.read() == 1) stopWell();
|
||||
if (startBtn.read() == 1 && stopBtn.read() == 1) {
|
||||
if (startBtn.read(poc.thisWell.ioMux) == 1) startWell();
|
||||
if (stopBtn.read(poc.thisWell.ioMux) == 1) stopWell();
|
||||
if (startBtn.read(poc.thisWell.ioMux) == 1 && stopBtn.read(poc.thisWell.ioMux) == 1) {
|
||||
exitPOC();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.bson.Document;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.lang.Math.abs;
|
||||
|
||||
@@ -27,9 +28,18 @@ public class Measurement {
|
||||
private Database db;
|
||||
private long lastSentTimestamp;
|
||||
private long sendTimeDelta;
|
||||
private String units = null;
|
||||
private boolean useTotal;
|
||||
private boolean useAverage;
|
||||
private long dbId;
|
||||
|
||||
Measurement(String tagName, Database db, double sendDelta, long sendTimeDelta){
|
||||
Measurement(String tagName, Database db, String units, double sendDelta, long sendTimeDelta, boolean useTotal, boolean useAverage){
|
||||
this.tagName = tagName;
|
||||
this.units = units;
|
||||
this.sendDelta = sendDelta;
|
||||
this.sendTimeDelta = sendTimeDelta;
|
||||
this.useTotal = useTotal;
|
||||
this.useAverage = useAverage;
|
||||
average = 0;
|
||||
total = 0;
|
||||
numMeasurements = 0;
|
||||
@@ -38,44 +48,51 @@ public class Measurement {
|
||||
|
||||
// Database code
|
||||
this.db = db;
|
||||
this.sendDelta = sendDelta;
|
||||
this.lastSentValue = 0.0;
|
||||
this.sendTimeDelta = sendTimeDelta;
|
||||
|
||||
Document lastStored = this.db.getLastStoredMeasurement(this.tagName);
|
||||
try {
|
||||
Date lastStoredTimestamp = (Date) lastStored.get("timestamp");
|
||||
ZonedDateTime timestamp = ZonedDateTime.ofInstant(lastStoredTimestamp.toInstant(),
|
||||
ZoneId.systemDefault());
|
||||
if (isToday(timestamp)){
|
||||
this.average = lastStored.getDouble("dailyAverage");
|
||||
this.total = lastStored.getDouble("dailyTotal");
|
||||
this.lastSentValue = lastStored.getDouble("currentValue");
|
||||
this.dailyMax = lastStored.getDouble("maxDailyValue");
|
||||
this.dailyMin = lastStored.getDouble("minDailyValue");
|
||||
this.lastSentTimestamp = timestamp.toEpochSecond();
|
||||
this.numMeasurements = lastStored.getLong("numMeasurements");
|
||||
System.out.println("Using stored value from " + timestamp.toString() + " for " + this.tagName);
|
||||
} else {
|
||||
System.out.println("Cannot use stored value from " + timestamp.toString() + " for " + this.tagName);
|
||||
}
|
||||
} catch (NullPointerException e){
|
||||
System.out.println("There was no previous measurement in the database for " + this.tagName);
|
||||
|
||||
this.dbId = this.db.tryNewMeasurementConfig(this);
|
||||
|
||||
double lastStored = this.db.getLastStoredMeasurement(this.dbId);
|
||||
if (lastStored != Double.MIN_VALUE) {
|
||||
this.lastSentValue = this.db.getLastStoredMeasurement(this.dbId);
|
||||
}
|
||||
// try {
|
||||
// Date lastStoredTimestamp = (Date) lastStored.get("dateStored");
|
||||
// ZonedDateTime timestamp = ZonedDateTime.ofInstant(lastStoredTimestamp.toInstant(),
|
||||
// ZoneId.systemDefault());
|
||||
// if (isToday(timestamp)){
|
||||
// this.average = lastStored.getDouble("averageValue");
|
||||
// this.total = lastStored.getDouble("totalValue");
|
||||
//// this.lastSentValue = lastStored.getDouble("currentValue");
|
||||
// this.dailyMax = lastStored.getDouble("maxValue");
|
||||
// this.dailyMin = lastStored.getDouble("minValue");
|
||||
// this.sendDelta = lastStored.getDouble("storeDelta");
|
||||
// this.sendTimeDelta = lastStored.getLong("storeTime");
|
||||
// this.units = lastStored.getString("units");
|
||||
//// this.lastSentTimestamp = timestamp.toEpochSecond();
|
||||
// Document values = (Document) lastStored.get("values");
|
||||
// Object[] hours = values.keySet().toArray();
|
||||
// String maxHour = (String) hours[hours.length - 1];
|
||||
// Document maxHourDoc = (Document) values.get(maxHour);
|
||||
// Object[] minutes = maxHourDoc.keySet().toArray();
|
||||
// String maxMinute = (String) minutes[minutes.length - 1];
|
||||
// this.lastSentValue = maxHourDoc.getDouble(maxMinute);
|
||||
// this.numMeasurements = lastStored.getLong("numMeasurements");
|
||||
//
|
||||
//
|
||||
// System.out.println("Using stored value from " + ZonedDateTime.of(timestamp.getYear(),
|
||||
// timestamp.getMonthValue(), timestamp.getDayOfMonth(), Integer.parseInt(maxHour),
|
||||
// Integer.parseInt(maxMinute), 0, 0, timestamp.getZone()).toString() + " for " + this.tagName);
|
||||
// } else {
|
||||
// System.out.println("Cannot use stored value from " + timestamp.toString() + " for " + this.tagName);
|
||||
// }
|
||||
// } catch (NullPointerException e){
|
||||
// System.out.println("There was no previous measurement in the database for " + this.tagName);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// Measurement(String tagName, boolean storeInDatabase){
|
||||
// this.tagName = tagName;
|
||||
// average = 0;
|
||||
// total = 0;
|
||||
// numMeasurements = 0;
|
||||
// dailyMax = Double.MIN_VALUE;
|
||||
// dailyMin = Double.MAX_VALUE;
|
||||
//
|
||||
// // Database code
|
||||
// this.storeInDatabase = storeInDatabase;
|
||||
// }
|
||||
|
||||
public double getCurrentValue() {
|
||||
return currentValue;
|
||||
@@ -109,6 +126,50 @@ public class Measurement {
|
||||
return dailyMin;
|
||||
}
|
||||
|
||||
public double getSendDelta() {
|
||||
return sendDelta;
|
||||
}
|
||||
|
||||
public void setSendDelta(double sendDelta) {
|
||||
this.sendDelta = sendDelta;
|
||||
}
|
||||
|
||||
public long getSendTimeDelta() {
|
||||
return sendTimeDelta;
|
||||
}
|
||||
|
||||
public void setSendTimeDelta(long sendTimeDelta) {
|
||||
this.sendTimeDelta = sendTimeDelta;
|
||||
}
|
||||
|
||||
public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
public void setUnits(String units) {
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
public boolean isUseTotal() {
|
||||
return useTotal;
|
||||
}
|
||||
|
||||
public void setUseTotal(boolean useTotal) {
|
||||
this.useTotal = useTotal;
|
||||
}
|
||||
|
||||
public boolean isUseAverage() {
|
||||
return useAverage;
|
||||
}
|
||||
|
||||
public void setUseAverage(boolean useAverage) {
|
||||
this.useAverage = useAverage;
|
||||
}
|
||||
|
||||
public long getDbId() {
|
||||
return dbId;
|
||||
}
|
||||
|
||||
private static boolean isToday(ZonedDateTime inpZDT){
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
if (now.toLocalDate().equals(inpZDT.toLocalDate())){
|
||||
@@ -131,7 +192,7 @@ public class Measurement {
|
||||
dailyMin = Math.min(dailyMin, currentValue);
|
||||
|
||||
if(abs(currentValue - lastSentValue) > sendDelta || (currentTimestamp - lastSentTimestamp) > (sendTimeDelta)){
|
||||
long l = db.newMeasurement(this);
|
||||
long l = db.newMeasurementValue(this);
|
||||
lastSentValue = currentValue;
|
||||
lastSentTimestamp = currentTimestamp;
|
||||
}
|
||||
|
||||
347
src/main/java/com/henrypump/poc/MongoDatabase.java
Normal file
347
src/main/java/com/henrypump/poc/MongoDatabase.java
Normal file
@@ -0,0 +1,347 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoCursor;
|
||||
import com.mongodb.client.model.*;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mongodb.client.model.Filters.and;
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
import static com.mongodb.client.model.Filters.lte;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 6/28/17.
|
||||
*/
|
||||
public class MongoDatabase {
|
||||
|
||||
private String pocDatabase = "poc";
|
||||
private MongoClient mongoClient;
|
||||
private com.mongodb.client.MongoDatabase database;
|
||||
private MongoCredential credential = MongoCredential.createCredential("poc_java", pocDatabase, "HenryPump@1903".toCharArray());
|
||||
private MongoCollection<Document> cardCollection, wellDataCollection, gaugeOffCollection, wellTestCollection,
|
||||
fluidShotsCollection, runStatusCollection, wellConfigCollection, setpointCollection;
|
||||
|
||||
public void initCollections(){
|
||||
cardCollection = database.getCollection("cards");
|
||||
cardCollection.createIndex(Indexes.ascending("timestamp", "strokeNumber"));
|
||||
|
||||
wellDataCollection = database.getCollection("measurements");
|
||||
wellDataCollection.createIndex(Indexes.ascending("dateStored", "tagName"));
|
||||
|
||||
gaugeOffCollection = database.getCollection("gaugeOff");
|
||||
gaugeOffCollection.createIndex(Indexes.ascending("timestamp", "tagName"));
|
||||
|
||||
|
||||
wellTestCollection = database.getCollection("wellTests");
|
||||
wellTestCollection.createIndex(Indexes.ascending("testStartTime"));
|
||||
|
||||
fluidShotsCollection = database.getCollection("fluidShots");
|
||||
fluidShotsCollection.createIndex(Indexes.ascending("timestamp"));
|
||||
|
||||
runStatusCollection = database.getCollection("runStatus");
|
||||
runStatusCollection.createIndex(Indexes.ascending("timestamp"));
|
||||
|
||||
wellConfigCollection = database.getCollection("wellConfiguration");
|
||||
wellConfigCollection.createIndex(Indexes.ascending("timestamp"));
|
||||
|
||||
setpointCollection = database.getCollection("setpoints");
|
||||
setpointCollection.createIndex(Indexes.ascending("name"));
|
||||
}
|
||||
|
||||
|
||||
MongoDatabase(){
|
||||
ServerAddress server = new ServerAddress("localhost", 27017);
|
||||
List<MongoCredential> credentials = Arrays.asList(credential);
|
||||
mongoClient = new MongoClient(server, credentials);
|
||||
database = mongoClient.getDatabase(pocDatabase);
|
||||
|
||||
initCollections();
|
||||
|
||||
|
||||
}
|
||||
|
||||
MongoDatabase(String dbHostname){
|
||||
ServerAddress server = new ServerAddress(dbHostname, 27017);
|
||||
List<MongoCredential> credentials = Arrays.asList(credential);
|
||||
mongoClient = new MongoClient(server, credentials);
|
||||
database = mongoClient.getDatabase(pocDatabase);
|
||||
|
||||
initCollections();
|
||||
}
|
||||
|
||||
public void close(){
|
||||
mongoClient.close();
|
||||
}
|
||||
|
||||
public long getLastStrokeNum(){
|
||||
|
||||
long lastStroke = 0;
|
||||
|
||||
MongoCollection<Document> collection = database.getCollection("cards");
|
||||
MongoCursor<Document> cursor = collection.aggregate(
|
||||
Arrays.asList(
|
||||
Aggregates.group("strokeNumber", Accumulators.last("lastStroke", "$strokeNumber"))
|
||||
)
|
||||
).iterator();
|
||||
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
long docStroke = cursor.next().getLong("lastStroke");
|
||||
if (docStroke > lastStroke) { lastStroke = docStroke; }
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
System.out.println("Found last stroke to be " + lastStroke);
|
||||
return lastStroke;
|
||||
}
|
||||
|
||||
public long newCard(Card inpCard){
|
||||
|
||||
List<Double> s_p = new ArrayList<Double>();
|
||||
List<Double> s_l = new ArrayList<Double>();
|
||||
List<Double> d_p = new ArrayList<Double>();
|
||||
List<Double> d_l = new ArrayList<Double>();
|
||||
int numPointsScan = inpCard.getNumPointsUsed();
|
||||
double[] sp = inpCard.getSurfacePosition();
|
||||
double[] sl = inpCard.getSurfaceLoad();
|
||||
double[] dp = inpCard.getDownholePosition();
|
||||
double[] dl = inpCard.getDownholeLoad();
|
||||
for(int i = 0; i < numPointsScan; i++ ) {
|
||||
s_p.add(sp[i]);
|
||||
s_l.add(sl[i]);
|
||||
d_p.add(dp[i]);
|
||||
d_l.add(dl[i]);
|
||||
}
|
||||
|
||||
Document doc = new Document("strokeNumber", inpCard.getStrokeNumber())
|
||||
.append("surface_position", s_p)
|
||||
.append("surface_load", s_l)
|
||||
.append("downhole_position", d_p)
|
||||
.append("downhole_load", d_l)
|
||||
.append("timestamp", Date.from(ZonedDateTime.now().toInstant()));
|
||||
cardCollection.insertOne(doc);
|
||||
System.out.println("Stored stroke number " + inpCard.getStrokeNumber() + " as " + doc.getObjectId("_id"));
|
||||
return cardCollection.count();
|
||||
}
|
||||
|
||||
|
||||
public long newMeasurement(Measurement inpMeasurement){
|
||||
ZonedDateTime nowDate = ZonedDateTime.now(ZoneId.of("UTC"));
|
||||
ZonedDateTime todayDate = ZonedDateTime.of(nowDate.getYear(), nowDate.getMonthValue(), nowDate.getDayOfMonth(), 0, 0, 0, 0, ZoneId.of("UTC"));
|
||||
Date storeDate = Date.from(todayDate.toInstant());
|
||||
Document nowMeasurement = new Document("values." + nowDate.getHour() + "." + nowDate.getMinute(), inpMeasurement.getCurrentValue())
|
||||
.append("currentValue", inpMeasurement.getCurrentValue())
|
||||
.append("maxValue", inpMeasurement.getDailyMax())
|
||||
.append("minValue", inpMeasurement.getDailyMin())
|
||||
.append("averageValue", inpMeasurement.getAverage())
|
||||
.append("totalValue", inpMeasurement.getTotal())
|
||||
.append("numMeasurements", inpMeasurement.getNumMeasurements())
|
||||
.append("units", inpMeasurement.getUnits())
|
||||
.append("storeDelta", inpMeasurement.getSendDelta())
|
||||
.append("storeTime", inpMeasurement.getSendTimeDelta())
|
||||
.append("useTotal", inpMeasurement.isUseTotal())
|
||||
.append("useAverage", inpMeasurement.isUseAverage())
|
||||
.append("dateStored", storeDate);
|
||||
|
||||
wellDataCollection.updateOne(and(eq("tagname", inpMeasurement.getTagName()), eq("dateStored", storeDate)), new Document("$set", nowMeasurement), (new UpdateOptions()).upsert(true));
|
||||
// wellDataCollection.updateOne(and(eq("tagname", inpMeasurement.getTagName()), eq("dateStored", todayDate)), new Document("$set", aggregateData), (new UpdateOptions()).upsert(true));
|
||||
|
||||
System.out.println("Stored " + inpMeasurement.getCurrentValue() + " for " + inpMeasurement.getTagName());
|
||||
return wellDataCollection.count();
|
||||
}
|
||||
|
||||
public Document getLastStoredMeasurement(String tagName){
|
||||
MongoCursor<Document> cursor = wellDataCollection.find(eq("tagname", tagName)).sort(Sorts.descending("dateStored")).limit(1).iterator();
|
||||
Document lastStoredDoc = new Document();
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastStoredDoc = cursor.next();
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
return lastStoredDoc;
|
||||
}
|
||||
|
||||
public long newDailyTotal(Measurement inpMeasurement){
|
||||
Document doc = new Document("tagname", inpMeasurement.getTagName())
|
||||
.append("currentValue", inpMeasurement.getCurrentValue())
|
||||
.append("maxDailyValue", inpMeasurement.getDailyMax())
|
||||
.append("minDailyValue", inpMeasurement.getDailyMin())
|
||||
.append("dailyAverage", inpMeasurement.getAverage())
|
||||
.append("dailyTotal", inpMeasurement.getTotal())
|
||||
.append("timestamp", Date.from(ZonedDateTime.now().toInstant()));
|
||||
gaugeOffCollection.insertOne(doc);
|
||||
return gaugeOffCollection.count();
|
||||
|
||||
}
|
||||
|
||||
public double getPreviousDailyTotal(ZonedDateTime inpDateTime){
|
||||
String isoInpDateTime = inpDateTime.toString();
|
||||
MongoCursor<Document> cursor = wellTestCollection.find(and(eq("tagname", "Fluid Produced"), lte("timestamp", isoInpDateTime)))
|
||||
.sort(Sorts.descending("timestamp")).limit(1).iterator();
|
||||
double lastTotal = -1.0;
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastTotal = cursor.next().getDouble("dailyTotal");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
return lastTotal;
|
||||
};
|
||||
|
||||
public long newWellTest(WellTest inp){
|
||||
Document doc = new Document("testStartTime", Date.from(inp.getTestStart().toInstant()))
|
||||
.append("testHours", inp.getTestHours())
|
||||
.append("testTotalBBL", inp.getTotalFluidBBL())
|
||||
.append("testOilBBL", inp.getTestOilBBL())
|
||||
.append("testWaterBBL", inp.getTestWaterBBL())
|
||||
.append("testGasMCF", inp.getTestGasMCF())
|
||||
.append("kFactor", inp.getkFactor())
|
||||
.append("oilRatio", inp.getOilRatio())
|
||||
.append("waterRatio", inp.getWaterRatio())
|
||||
.append("gasMCFRatio", inp.getGasMCFRatio());
|
||||
wellTestCollection.insertOne(doc);
|
||||
return wellTestCollection.count();
|
||||
}
|
||||
|
||||
public Document getPreviousWellTest(ZonedDateTime inpDateTime){
|
||||
MongoCursor<Document> cursor = wellTestCollection.find(lte("testStartTime", Date.from(inpDateTime.toInstant())))
|
||||
.sort(Sorts.descending("testStartTime")).limit(1).iterator();
|
||||
Document lastTest = new Document("kFactor", (Double) 1.0);
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastTest = cursor.next();
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
return lastTest;
|
||||
};
|
||||
|
||||
public double getLatestKFactor(){
|
||||
MongoCursor<Document> cursor = wellTestCollection.find().sort(Sorts.descending("testStartTime")).limit(1).iterator();
|
||||
double kFactor = 1.0;
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
kFactor = cursor.next().getDouble("kFactor");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
return kFactor;
|
||||
}
|
||||
|
||||
public long newFluidShot(FluidShot inp){
|
||||
String df = ZonedDateTime.now().toString();
|
||||
Document doc = new Document("timestamp", Date.from(ZonedDateTime.now().toInstant()))
|
||||
.append("fluidLevel", inp.getFluidLevel())
|
||||
.append("pumpIntakePressure", inp.getPumpIntakePressure())
|
||||
.append("frictionEstimate", inp.getFrictionEstimate());
|
||||
fluidShotsCollection.insertOne(doc);
|
||||
return fluidShotsCollection.count();
|
||||
}
|
||||
|
||||
public double getLatestFrictionEstimate(){
|
||||
MongoCursor<Document> cursor = fluidShotsCollection.find().sort(Sorts.descending("timestamp")).limit(1).iterator();
|
||||
double frictionEstimate = -1;
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
frictionEstimate = cursor.next().getDouble("frictionEstimate");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
return frictionEstimate;
|
||||
}
|
||||
|
||||
public long newRunStatus(String runStatus, String initiator){
|
||||
Document doc = new Document("status", runStatus)
|
||||
.append("initiator", initiator)
|
||||
.append("timestamp", Date.from(ZonedDateTime.now().toInstant()));
|
||||
runStatusCollection.insertOne(doc);
|
||||
return runStatusCollection.count();
|
||||
}
|
||||
|
||||
public long storeWellSetup(Well thisWell){
|
||||
ArrayList<Document> taperArr = new ArrayList<Document>();
|
||||
for (int i = 1; i <= thisWell.getNumTapers(); i++){
|
||||
Document tap = new Document("length", thisWell.getRodLength(i))
|
||||
.append("diameter", thisWell.getRodDiameter(i))
|
||||
.append("material", thisWell.getRodMaterial(i))
|
||||
.append("dampingFactor", thisWell.getDampingFactor(i));
|
||||
taperArr.add(tap);
|
||||
}
|
||||
|
||||
|
||||
Document doc = new Document("timestamp", Date.from(ZonedDateTime.now().toInstant()))
|
||||
.append("wellName", thisWell.getWellName())
|
||||
.append("deltaT", thisWell.getDt())
|
||||
.append("pumpDiameter", thisWell.getPumpDiameter())
|
||||
.append("fluidGradient", thisWell.getFluidGradient())
|
||||
.append("tubingID", thisWell.getTubingID())
|
||||
.append("tubingOD", thisWell.getTubingOD())
|
||||
.append("tubingAnchorDepth", thisWell.getTubingAnchorDepth())
|
||||
.append("structuralRating", thisWell.getStructuralRating())
|
||||
.append("stuffingBoxFriction", thisWell.getSbfriction())
|
||||
.append("tubingHeadPressure", thisWell.getTubingHeadPressure())
|
||||
.append("tapers", taperArr)
|
||||
.append("storedBy", "poc");
|
||||
|
||||
wellConfigCollection.insertOne(doc);
|
||||
return wellConfigCollection.count();
|
||||
}
|
||||
|
||||
public Document getLatestWellConfiguration(){
|
||||
MongoCursor<Document> cursor = wellConfigCollection.find().sort(Sorts.descending("timestamp")).limit(1).iterator();
|
||||
Document lastConfig = new Document();
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastConfig = cursor.next();
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
return lastConfig;
|
||||
}
|
||||
|
||||
public long storeSetpoint(String setpointName, double setpointValue){
|
||||
Document newSetpoint = new Document("name", setpointName)
|
||||
.append("value", setpointValue)
|
||||
.append("lastStored", Date.from(ZonedDateTime.now().toInstant()))
|
||||
.append("storedBy", "poc");
|
||||
setpointCollection.updateOne(eq("name", setpointName), new Document("$set", newSetpoint), (new UpdateOptions()).upsert(true));
|
||||
return setpointCollection.count();
|
||||
|
||||
}
|
||||
|
||||
public Double getSetpoint(String setpointName){
|
||||
Document setpointDoc = setpointCollection.find(eq("name", setpointName)).first();
|
||||
double setpoint;
|
||||
try {
|
||||
setpoint = setpointDoc.getDouble("value");
|
||||
String storedBy = setpointDoc.getString("storedBy");
|
||||
System.out.println("Setpoint retrieved from database: [" + setpointName + " = " + setpoint + " stored by " + storedBy + "]");
|
||||
} catch (ClassCastException e){
|
||||
setpoint = Double.parseDouble(setpointDoc.get("value").toString());
|
||||
String storedBy = setpointDoc.getString("storedBy");
|
||||
System.out.println("Setpoint retrieved from database: [" + setpointName + " = " + setpoint + " stored by " + storedBy + "]");
|
||||
} catch (NullPointerException e){
|
||||
setpoint = Double.MIN_VALUE;
|
||||
System.out.println("Could not find a value for " + setpointName + " in the database.");
|
||||
}
|
||||
return setpoint;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 2/1/17.
|
||||
* POC Class
|
||||
@@ -15,16 +13,16 @@ public class POC implements Runnable{
|
||||
|
||||
POC(String dbHostname){
|
||||
ioEnabled = true;
|
||||
thisWell = new Well(dbHostname, 0, 1, 7);
|
||||
thisWell = new Well(dbHostname, 1, 2);
|
||||
thisWell.getWellSetup();
|
||||
}
|
||||
|
||||
POC(String simFileName, boolean ioEnabled, String dbHostname){
|
||||
this.ioEnabled = ioEnabled;
|
||||
if (this.ioEnabled) {
|
||||
thisWell = new Well(dbHostname, simFileName,0, 1, 7);
|
||||
thisWell = new Well(dbHostname, simFileName,1, 2);
|
||||
} else {
|
||||
thisWell = new Well(dbHostname, simFileName,99, 99, 99);
|
||||
thisWell = new Well(dbHostname, simFileName,99, 99);
|
||||
}
|
||||
thisWell.getWellSetup();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.internal.bind.JsonTreeReader;
|
||||
import com.henrypump.rpio.AnalogIn;
|
||||
import com.henrypump.rpio.MuxSetup;
|
||||
import de.vandermeer.asciitable.v2.RenderedTable;
|
||||
import de.vandermeer.asciitable.v2.V2_AsciiTable;
|
||||
import de.vandermeer.asciitable.v2.render.V2_AsciiTableRenderer;
|
||||
@@ -16,12 +20,16 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static java.lang.Math.*;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 1/31/17.
|
||||
*/
|
||||
@@ -34,6 +42,7 @@ public class Well {
|
||||
/* IO */
|
||||
private AnalogIn inclinometer;
|
||||
private AnalogIn loadCell;
|
||||
MuxSetup ioMux = new MuxSetup();
|
||||
private double currentSurfacePosition;
|
||||
private double currentSurfaceLoad;
|
||||
private double currentDownholePosition;
|
||||
@@ -201,20 +210,20 @@ public class Well {
|
||||
private long minutesSinceTimerStart_last = 0;
|
||||
|
||||
|
||||
Well(String dbHostname, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
|
||||
Well(String dbHostname, int inclinometerChannel, int loadCellChannel){
|
||||
this.wellName = wellName;
|
||||
db = new Database(dbHostname);
|
||||
strokesLifetime = db.getLastStrokeNum() + 1;
|
||||
currentCard = new Card(strokesLifetime);
|
||||
inclinometer = new AnalogIn(inclinometerChannel, 0, 1020, 0, 145);
|
||||
loadCell = new AnalogIn(loadCellChannel, 0, 1020, 0, 50000);
|
||||
inclinometer = new AnalogIn(inclinometerChannel, 0, 65535, 0, 145);
|
||||
loadCell = new AnalogIn(loadCellChannel, 0, 65535, 0, 50000);
|
||||
|
||||
initializeMeasurements();
|
||||
initializeSetpoints();
|
||||
db.newRunStatus("Boot", "io");
|
||||
}
|
||||
|
||||
Well(String dbHostname, String simFileName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
|
||||
Well(String dbHostname, String simFileName, int inclinometerChannel, int loadCellChannel){
|
||||
this.wellName = wellName;
|
||||
sim = new Simulation(simFileName);
|
||||
db = new Database(dbHostname);
|
||||
@@ -228,6 +237,32 @@ public class Well {
|
||||
db.newRunStatus("Boot", "commandline");
|
||||
}
|
||||
|
||||
private int[] calibrateInclinometer(){
|
||||
System.out.println("Calibrating inclinometer...");
|
||||
Instant startTime = Instant.now();
|
||||
int maxRaw = Integer.MIN_VALUE;
|
||||
int minRaw = Integer.MAX_VALUE;
|
||||
while (Duration.between(startTime, Instant.now()).toMillis() < 30000){
|
||||
inclinometer.read(ioMux);
|
||||
if (inclinometer.getRawValue() > maxRaw){
|
||||
maxRaw = inclinometer.getRawValue();
|
||||
}
|
||||
|
||||
if (inclinometer.getRawValue() < minRaw){
|
||||
minRaw = inclinometer.getRawValue();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
int minMax[] = new int[]{minRaw, maxRaw};
|
||||
System.out.println("Inclinometer Min: " + minRaw + ", Inclinometer Max: " + maxRaw);
|
||||
return minMax;
|
||||
};
|
||||
|
||||
private void initializeSetpoints(){
|
||||
/**
|
||||
* intializeSetpoints
|
||||
@@ -318,26 +353,27 @@ public class Well {
|
||||
}
|
||||
|
||||
private void initializeMeasurements(){
|
||||
strokeSpeed = new Measurement("Stroke Speed", db, 0.5, 600);
|
||||
downholeGrossStroke = new Measurement("Downhole Gross Stroke", db, 0.5, 600);
|
||||
downholeNetStroke = new Measurement("Downhole Net Stroke", db, 0.5, 600);
|
||||
fluidLevel = new Measurement("Fluid Level", db, 10, 600);
|
||||
fluidLoad = new Measurement("Fluid Load", db, 20, 600);
|
||||
inflowRate = new Measurement("Inflow Rate", db, 0.5, 600);
|
||||
peakPolishedRodLoad = new Measurement("Peak PRL", db, 50, 600);
|
||||
minPolishedRodLoad = new Measurement("Min PRL", db, 50, 600);
|
||||
percentRun = new Measurement("Percent Run", db, 1.0, 600);
|
||||
polishedRodHP = new Measurement("Polished Rod HP", db, 0.25, 600);
|
||||
pumpHP = new Measurement("Pump HP", db, 0.25, 600);
|
||||
fluidProduced = new Measurement("Fluid Produced", db, 1.0, 600);
|
||||
fluidProducedAdjusted = new Measurement("Fluid Produced (adjusted)", db, 1.0, 600);
|
||||
oilProduced = new Measurement("Oil Produced", db, 1.0, 600);
|
||||
waterProduced = new Measurement("Water Produced", db, 1.0, 600);
|
||||
gasProduced = new Measurement("Gas Produced", db, 1.0, 600);
|
||||
pumpIntakePressure = new Measurement("Pump Intake Pressure", db, 5.0, 600);
|
||||
surfaceStrokeLength = new Measurement("Surface Stroke", db, 0.5, 1800);
|
||||
tubingMovement = new Measurement("Tubing Movement", db, 0.5, 600);
|
||||
pumpFillPercent = new Measurement("Pump Fill Percent", db, 0.5, 600);
|
||||
strokeSpeed = new Measurement("Stroke Speed", db, "SPM", 0.5, 600, true, false);
|
||||
downholeGrossStroke = new Measurement("Downhole Gross Stroke", db, "in.", 0.5, 600, true, false);
|
||||
downholeNetStroke = new Measurement("Downhole Net Stroke", db, "in.", 0.5, 600, true, false);
|
||||
fluidLevel = new Measurement("Fluid Level", db, "ft.", 10.0, 600, true, false);
|
||||
fluidLoad = new Measurement("Fluid Load", db, "lbs.", 20.0, 600, true, false);
|
||||
inflowRate = new Measurement("Inflow Rate", db, "BBL/day", 0.5, 600, true, false);
|
||||
peakPolishedRodLoad = new Measurement("Peak PRL", db, "lbs.", 50, 600, true, false);
|
||||
minPolishedRodLoad = new Measurement("Min PRL", db, "lbs.", 50.0, 600, true,false);
|
||||
percentRun = new Measurement("Percent Run", db, "%", 0.5, 600, false, false);
|
||||
polishedRodHP = new Measurement("Polished Rod HP", db, "HP", 0.25, 600, true,false);
|
||||
pumpHP = new Measurement("Pump HP", db, "HP", 0.25, 600, true, false);
|
||||
fluidProduced = new Measurement("Fluid Produced", db, "BBL", 1.0, 600, true, true);
|
||||
fluidProducedAdjusted = new Measurement("Fluid Produced (adjusted)", db, "BBL", 1.0, 600, true, true);
|
||||
oilProduced = new Measurement("Oil Produced", db, "BBL", 0.5, 600, true, true);
|
||||
waterProduced = new Measurement("Water Produced", db, "BBL", 1.0, 600, true, true);
|
||||
gasProduced = new Measurement("Gas Produced", db, "MCF", 1.0, 600, true, true);
|
||||
pumpIntakePressure = new Measurement("Pump Intake Pressure", db, "PSI", 5.0, 600, true, false);
|
||||
surfaceStrokeLength = new Measurement("Surface Stroke", db, "in.", 0.5, 600, true, false);
|
||||
tubingMovement = new Measurement("Tubing Movement", db, "in.", 0.5, 600, true, false);
|
||||
pumpFillPercent = new Measurement("Pump Fill Percent", db, "%", 1.0, 600, true, false);
|
||||
|
||||
}
|
||||
|
||||
public double getDt() {
|
||||
@@ -692,6 +728,8 @@ public class Well {
|
||||
strokesSinceStart = 0;
|
||||
pumpStartTime = ZonedDateTime.now();
|
||||
db.newRunStatus(getRunStatusString(), initiator);
|
||||
int[] inclMinMax = calibrateInclinometer();
|
||||
inclinometer = new AnalogIn(inclinometer.getChannel(), inclMinMax[0], inclMinMax[1], inclinometer.getEuMin(), inclinometer.getEuMax());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,6 +821,7 @@ public class Well {
|
||||
};
|
||||
|
||||
void getWellSetup(){
|
||||
Gson gson = new Gson();
|
||||
String jsonFilename = "wellSetup.json";
|
||||
JSONParser parser = new JSONParser();
|
||||
try {
|
||||
@@ -852,55 +891,70 @@ public class Well {
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("No configuration file found. Pulling latest value from database.");
|
||||
Document newConfigDoc = db.getLatestWellConfiguration();
|
||||
JsonObject newConfigDoc = db.getLatestWellConfiguration();
|
||||
|
||||
Object newWellName = newConfigDoc.get("wellName");
|
||||
if (newWellName != null) wellName = (String) newWellName;
|
||||
|
||||
Object newDeltaT = newConfigDoc.get("deltaT");
|
||||
if (newDeltaT != null) dt = (Double) newDeltaT;
|
||||
JsonPrimitive wellConfigPrimitive = newConfigDoc.getAsJsonPrimitive("well_config");
|
||||
String wellConfigString = wellConfigPrimitive.getAsString();
|
||||
JsonObject wellConfig = gson.fromJson(wellConfigString, JsonObject.class);
|
||||
|
||||
Object newPumpDiameter = newConfigDoc.get("pumpDiameter");
|
||||
if (newPumpDiameter != null) setPumpDiameter((Double) newPumpDiameter);
|
||||
|
||||
Object newFluidGradient = newConfigDoc.get("fluidGradient");
|
||||
if (newFluidGradient != null) fluidGradient = (Double) newFluidGradient;
|
||||
JsonElement newWellName = wellConfig.get("wellName");
|
||||
if (newWellName != null) wellName = newWellName.getAsString();
|
||||
|
||||
Object newTubingID = newConfigDoc.get("tubingID");
|
||||
if (newTubingID != null) setTubingID((Double) newTubingID);
|
||||
JsonElement newDeltaT = wellConfig.get("deltaT");
|
||||
if (newDeltaT != null) dt = newDeltaT.getAsDouble();
|
||||
|
||||
Object newTubingOD = newConfigDoc.get("tubingOD");
|
||||
if (newTubingOD != null) setTubingOD((Double) newTubingOD);
|
||||
JsonElement newPumpDiameter = wellConfig.get("pumpDiameter");
|
||||
if (newPumpDiameter != null) setPumpDiameter(newPumpDiameter.getAsDouble());
|
||||
|
||||
Object newTubingAnchorDepth = newConfigDoc.get("tubingAnchorDepth");
|
||||
if (newTubingAnchorDepth != null) tubingAnchorDepth = (Double) newTubingAnchorDepth;
|
||||
JsonElement newFluidGradient = wellConfig.get("fluidGradient");
|
||||
if (newFluidGradient != null) fluidGradient = newFluidGradient.getAsDouble();
|
||||
|
||||
Object newStructuralRating = newConfigDoc.get("structuralRating");
|
||||
if (newStructuralRating != null) structuralRating = (Double) newStructuralRating;
|
||||
JsonElement newTubingID = wellConfig.get("tubingID");
|
||||
if (newTubingID != null) setTubingID(newTubingID.getAsDouble());
|
||||
|
||||
Object newStuffingBoxFriction = newConfigDoc.get("stuffingBoxFriction");
|
||||
if (newStuffingBoxFriction != null) setSbfriction((Double) newStuffingBoxFriction);
|
||||
JsonElement newTubingOD = wellConfig.get("tubingOD");
|
||||
if (newTubingOD != null) setTubingOD(newTubingOD.getAsDouble());
|
||||
|
||||
Object newTubingHeadPressure = newConfigDoc.get("tubingOD");
|
||||
if (newTubingHeadPressure != null) setTubingOD((Double) newTubingHeadPressure);
|
||||
JsonElement newTubingAnchorDepth = wellConfig.get("tubingAnchorDepth");
|
||||
if (newTubingAnchorDepth != null) tubingAnchorDepth = newTubingAnchorDepth.getAsDouble();
|
||||
|
||||
ArrayList<Document> tapers = (ArrayList<Document>) newConfigDoc.get("tapers");
|
||||
numTapers = tapers.size();
|
||||
for (int i = 0; i < numTapers; i++) {
|
||||
int currentTaperNum = i + 1;
|
||||
Document taperObj = tapers.get(i);
|
||||
JsonElement newStructuralRating = wellConfig.get("structuralRating");
|
||||
if (newStructuralRating != null) structuralRating = newStructuralRating.getAsDouble();
|
||||
|
||||
Object newLength = taperObj.get("length");
|
||||
if (newLength != null) setRodLength(currentTaperNum, (Double) newLength);
|
||||
JsonElement newStuffingBoxFriction = wellConfig.get("stuffingBoxFriction");
|
||||
if (newStuffingBoxFriction != null) setSbfriction(newStuffingBoxFriction.getAsDouble());
|
||||
|
||||
Object newDiameter = taperObj.get("diameter");
|
||||
if (newDiameter != null) setRodDiameter(currentTaperNum, (Double) newDiameter);
|
||||
JsonElement newTubingHeadPressure = wellConfig.get("tubingOD");
|
||||
if (newTubingHeadPressure != null) setTubingOD(newTubingHeadPressure.getAsDouble());
|
||||
|
||||
Object newMaterial = taperObj.get("material");
|
||||
if (newMaterial != null) setRodYM(currentTaperNum, (String) newMaterial);
|
||||
JSONParser jparser = new JSONParser();
|
||||
JsonPrimitive taperPrimitive = newConfigDoc.getAsJsonPrimitive("tapers");
|
||||
String taperString = taperPrimitive.getAsString();
|
||||
try {
|
||||
JSONArray tapers = (JSONArray) parser.parse(taperString);
|
||||
|
||||
Object newDampingFactor = taperObj.get("dampingFactor");
|
||||
if (newDampingFactor != null) setDampingFactor(currentTaperNum, (Double) newDampingFactor);
|
||||
// JsonObject tapers = gson.fromJson(taperString, JsonObject.class);
|
||||
numTapers = tapers.size();
|
||||
for (int i = 0; i < numTapers; i++) {
|
||||
int currentTaperNum = i + 1;
|
||||
JSONObject taperObj = (JSONObject) tapers.get(i);
|
||||
|
||||
Object newLength = taperObj.get("length");
|
||||
if (newLength != null) setRodLength(currentTaperNum, (Double) newLength);
|
||||
|
||||
Object newDiameter = taperObj.get("diameter");
|
||||
if (newDiameter != null) setRodDiameter(currentTaperNum, (Double) newDiameter);
|
||||
|
||||
Object newMaterial = taperObj.get("material");
|
||||
if (newMaterial != null) setRodYM(currentTaperNum, (String) newMaterial);
|
||||
|
||||
Object newDampingFactor = taperObj.get("dampingFactor");
|
||||
if (newDampingFactor != null) setDampingFactor(currentTaperNum, (Double) newDampingFactor);
|
||||
}
|
||||
} catch (ParseException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
updateTapers(false);
|
||||
} catch (IOException | ParseException e) {
|
||||
@@ -1351,8 +1405,8 @@ public class Well {
|
||||
|
||||
public void eval(){
|
||||
checkSafeties();
|
||||
currentSurfacePosition = inclinometer.readScaled();
|
||||
currentSurfaceLoad = loadCell.readScaled();
|
||||
currentSurfacePosition = inclinometer.read(ioMux);
|
||||
currentSurfaceLoad = loadCell.read(ioMux);
|
||||
LPStatus lastPoint = calc(currentSurfacePosition, currentSurfaceLoad);
|
||||
if (lastPoint.getStatus() == GOOD_STATUS){
|
||||
currentDownholePosition = lastPoint.getPosition();
|
||||
@@ -1415,8 +1469,8 @@ public class Well {
|
||||
|
||||
public void eval(int simPoint){
|
||||
checkSafeties();
|
||||
currentSurfacePosition = inclinometer.readScaledSim(sim.getPositionAtIndex(simPoint));
|
||||
currentSurfaceLoad = loadCell.readScaledSim(sim.getLoadAtIndex(simPoint));
|
||||
currentSurfacePosition = inclinometer.readSim(sim.getPositionAtIndex(simPoint));
|
||||
currentSurfaceLoad = loadCell.readSim(sim.getLoadAtIndex(simPoint));
|
||||
|
||||
LPStatus lastPoint = calc(currentSurfacePosition, currentSurfaceLoad);
|
||||
if (lastPoint.getStatus() == GOOD_STATUS){
|
||||
@@ -1509,7 +1563,7 @@ public class Well {
|
||||
|
||||
|
||||
public static void main( String[] args ){
|
||||
Well thisWell = new Well(args[1], 99, 99, 99);
|
||||
Well thisWell = new Well(args[1], 99, 99);
|
||||
thisWell.getWellSetup();
|
||||
thisWell.printTapers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user