Code Monkey home page Code Monkey logo

alpycadevice's People

Contributors

bobdenny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

alpycadevice's Issues

Missing line of code in focuser.py possibly other places.

It looks like a line of code is missing in the new focuser.py class connected at line 88

       # --------------------------------
        ### CONNECT/DISCONNECT()PARAM) ###
        # --------------------------------
       resp.text = MethodResponse(req).json
    except Exception as ex:
        DriverException(0x500, 'Focuser.{Memname} failed', ex)).json

I think it should be:
# --------------------------------
### CONNECT/DISCONNECT()PARAM) ###
# --------------------------------
resp.text = MethodResponse(req).json
except Exception as ex:
resp.text = MethodResponse(None, req,
DriverException(0x500, 'Focuser.{Memname} failed', ex)).json
Also there is an extra right parentheses at the end of line 79.

Thanks for creating this

Bob, thanks for releasing this. I've used it to make a Raspberry Pi Camera driver which you can find here. https://github.com/IanCassTwo/rpicam-ascom-alpaca.

On the whole, it was quite easy to do but there was a few oddities and things that I struggled with.

  1. The camera template has some duplicate on_put methods with the same signature in some classes. I couldn't see why they were there so I deleted them

  2. Some property responses want more fields other than just "Value" so I ended up subclassing the Property Response class under a new name to suit. Not sure if there's a better way to do it

  3. The biggest thing I struggled with was getting the ImageArray in the correct format. I got there eventually but documentation regarding this is terrible on the ASCOM site.

Connected Method Missing from Templates

I am a novice programmer and believe based on your videos that the goal is to make this package a very skinny and simple template for someone to get started writing an Alpaca Driver. I really appreciate this package!! I looked all over for days on how to get started writing my own ASCOM COM or Alpaca driver when I could not find something existing to do what I needed. So I am not sure if this is an Issue or intentional. So please forgive me if it was intentional and feel free to ignore this post if it was.

In the original example, there is a "connected" class in the rotator.py example (with both on_get and on_put). From what I understand, all these classes in the .py (rotator.py for example) are used to generate the URI's (ASCOM Alpaca Methods) for each device. From reading the documentation and the ASCOM API website, this "method" appears to be required of all devices (https://ascom-standards.org/api/#/ASCOM%20Methods%20Common%20To%20All%20Devices). The example compiles and passes the ConformU tests. It appears that all the common and device specific methods except "connected" are in the templates.

But when trying to follow the directions for building your own driver using the templates, after trying to run ConformU, I kept getting "404 (NotFound)" errors on all "GET Connected" tests. It took me a lot of time to finally figure out there is no "class connected" in the template I was using (and appears all). Unless I missed it, the documentation did not mention this missing "class connected" in the template. Without the "class connected", it fails conformity testing at the most basic level (404 errors).

So I added back a generic version of the rotator.py example "class connected:" as follows:

@before(PreProcessRequest(maxdev))
class connected:
    """Retrieves or sets the connected state of the device

    * Set True to connect to the device hardware. Set False to disconnect
      from the device hardware. Client can also read the property to check
      whether it is connected. This reports the current hardware state.
    * Multiple calls setting Connected to true or false must not cause
      an error.
   """

    def on_get(self, req: Request, resp: Response, devnum: int):
        resp.text = PropertyResponse(True, req).json

    def on_put(self, req: Request, resp: Response, devnum: int):
        try:
            resp.text = MethodResponse(req).json
        except Exception as ex:
            resp.text = MethodResponse(req, # Put is actually like a method :-(
                            DriverException(0x500, f'{self.__class__.__name__} failed', ex)).json

It still does not pass the ConformU due to some tests of "bad parameters" being passed (Empty string, Number, Meaningless string), but all of the 404 errors went away.

I know this needs to actually test the connection status (on_get) and connect/disconnect (on_put) and to test the passed values are in range, but it gets rid of the 404 errors and let's me know I need to deal with this method. I would recommend that either the a "class connected" be included with each template or the documentation notes the need for this class to be added to every template.

Log files created are named "rotatorXXX.log" even when other device

When using the code as described in the documentation to create a different device, for example ObservingConditions, the log file that is generated is "rotatorXXX.log" instead of say "observingconditionsXXX.log". In the log.py file, line 74 appears to have the name of the log file hard coded to "rotator.log". Might want to add this to your changes in the documentation to modify this line in log.py or add it as a config.toml setting.

2023-07-28_22-27-04

ObservingConditions Template Exception

When trying to use the observingconditions.py template as described in the documentation, when I try to run the code, I get the following error:
2023-07-28_22-04-18

I am not a well versed programmer and brand new to Python, but I dropped "to_int" (and later "to_float" when that produced a similar error) and that seems to work. I am not sure if it can't find those to import, does not need them, or were not defined for some reason.

Device-Specific setup routing bug

The routing for device-specific setup captures the device number with the wrong name. It is devno yet all of the responders expect devnum. This causes the device-specific setup endpoint to fail with a 500 error.

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.