Giter Site home page Giter Site logo

Comments (7)

ChristianTremblay avatar ChristianTremblay commented on July 21, 2024 1

I like that, it adds a nice scripting possibility to pyhaystack.

from pyhaystack.

sjlongland avatar sjlongland commented on July 21, 2024

If you can point us to documentation on how to do that, sure. We'll look at adding it.

At the moment, the only way I know of in nHaystack to edit the asset model is via the workbench, and I have no idea how entities get into SkySpark. The only implementation that I know of which supports this is WideSky.

from pyhaystack.

sjlongland avatar sjlongland commented on July 21, 2024

Related issue: #74

from pyhaystack.

mschrader15 avatar mschrader15 commented on July 21, 2024

@sjlongland You are probably right. I will reach out to SkySpark and see if it is even possible per #74

I'll close this issue for now

from pyhaystack.

mschrader15 avatar mschrader15 commented on July 21, 2024

Follow up to this, I was able to add new equipment points to our skyspark server using:

    def _create_equipment_grid(self, equip_name, markers):
        grid = hszinc.Grid()
        grid.metadata['commit'] = 'add'
        # grid.metadata['projName'] = 'Springfield'
        grid.column['dis'] = {}
        grid.column["equip"] = {}
        grid.column["siteRef"] = {}
        grid.column["navName"] = {}
        #grid.column['disMacro'] = {}
        g = {'dis': equip_name, 'navName': equip_name, 'equip': hszinc.MARKER, "siteRef": self._site.id}
        for marker in markers:
            grid.column[marker] = {}
            g[marker] = hszinc.MARKER
        grid.append(g)
        return grid

and then passing the grid to PyHaystack's protected _post_grid method:

    def _post_grid(self, g):
        r = self.session._post_grid(grid=g, callback=None, uri='commit')
        return r

I added measurement points in the same way:

    def _create_measurement_grid(self, method, name, markers, unit, kind,):
        grid = hszinc.Grid()
        grid.metadata['commit'] = 'add'
        # grid.column['dis'] = {}
        grid.column['navName'] = {}
        grid.column['disMacro'] = {}
        grid.column["siteRef"] = {}
        grid.column["equipRef"] = {}
        grid.column["tz"] = {}
        grid.column["kind"] = {}
        g = {'navName': name, 'disMacro': '$equipRef $navName', "siteRef": self._site.id, "equipRef": self._equip.id,
             'unit': unit, 'tz': str(self._site.hs_tz), 'kind': kind}
        for marker in markers:
            grid.column[marker] = {}
            g[marker] = hszinc.MARKER
        grid.append(g)
        return grid

where method is 'add'

from pyhaystack.

sjlongland avatar sjlongland commented on July 21, 2024

This is an interesting development indeed.

To achieve parity with what WideSky permits, we'd need the ability to:

  • add new entities (commit endpoint looks to be the one that does this)
  • mutate entities (maybe doable via commit as well) by:
    • adding new tags
    • changing the values of existing tags
    • deleting tags
  • delete entities

If we can do those things, say via curl, we can most certainly implement it in pyhaystack. The "CRUD" operations in WideSky would be a good starting point for implementing this.

from pyhaystack.

mschrader15 avatar mschrader15 commented on July 21, 2024

I have had success mutating existing entities in SkySpark using:
grid.metadata['commit'] = 'update' instead of grid.metadata['commit'] = 'add'. In both cases I used the commit endpoint
I have used this to add new tags, though haven't tried to overwrite or remove existing tags.

We actually just ran into a use case where it would've been convenient to delete entities using pyhaystack, but the low # of entities made it more efficient to just delete them using SkySparks UI

from pyhaystack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.