Default Green Orange
Marcus Follrud
Wish I had a slogan
RSS
  • Home Page Home
  • Cruel Chipmunk Productions
  • Om
  • Projects

Programmering Category

Axis Parameter Class for Python

Open source, Programmering 0 Comment »

A couple of days ago I was in need of making some scripts that removed duplicate parameter groups on a couple of Axis devices. For those of you who don’t know, Axis creates Digital Surveillance Cameras with IP technology, which in practice means that It’s surveillance cameras running Linux.

All Axis devices offers an open API for developers who want to develop  that uses Axis devices. The most frequent API used is the Parameter API, that allows to change basic settings, create motion detection windows, events with triggers and so on. And this is the API that I had to implement a class for.

The class is written in Python and is pretty much an object oriented interface. Example

param1 = AxisParameter("Motion.M0.Left","1120")
#param1.name = Motion.M0.Left, param1.value = "1120"
param2 = AxisParameter("Properties.Resolution")
#param2.name = Properties.Resolution, param2.value = None

Here we have two parameters that can be accessed from the class. param1 contains a parameter with an assigned value to it, this can be used to modify an already existing parameter. param2 contains a parameter name, but have no idea of the value of it, better used to receive the parameters

To use the class, you must first import the data from it.

from AxisParameterClass import * #import both the working class and the information class

paramclass = AxisParameterClass("some.ip","username","password","vapixversion")

All arguments are optional and can be set later with the following functions

  • setIP
  • setCredentials
  • setVapixVersion

Axis currently have two API’s for handling vapix parameters. The only big difference is the URL, but still. The class will automatically try to determine the vapix version if not set before.

Receive parameters

To get parameters from a device, simply create a parameter that you’re interesting, both groups and subgroups are fine to use:

paramclass.getParameters([AxisParameter('Motion'), AxisParameter('Properties'), AxisParameter('NonExistent')])

The class will return a list of all parameters that matches the search. Is a parameter not found, the Parameter will be returned with the value None. All parameters that are found have their value as a string.

Remove parameters

Just as add. Create your list, and send to

paramclass.removeParameters([AxisParameter('Motion')])

Parameters returned have a status parameter that refers if the parameter was removed or not:

AxisParameter.status = "OK" #removed
AxisParameter.status = "Error" #not removed.

Update Parameters (Implementation still needs some work)

To update, pass the list into

paramclass.updateParameters([AxisParameter('Motion.M0.Left','1123')] )

If all works, the parameters returned will contain the same result as what you passed in.

 

Download

It can all be downloaded from github, licensed under MIT, so feel free to do whatever you like with it :)
https://github.com/marcusfollrud/AxisParameterPython 


januari 24th, 2012  



dopingkollen.se

Open source, Programmering 0 Comment »

Hej Vänner!

För några dagar sedan hade jag och några vänner en diskussion kring kosttillskott och ”misstagsdoping”. Finns misstagsdoping egentligen? Behöver man kosttillskott? Frågorna var många och vi hade väl ungefär lika många svar. Men samtidigt som jag var mitt uppe i diskussionen pågick där parallellt en härlig problemlösning i bakhuvudet som bara kommer fram vid programmeringstillfälle. Hur skulle det vara ifall man hade en databas som hade koll på vilka produkter som var stämplade som dopingklassade?Med innehållsförteckning, länkar mot nyheter osv osv?

Av att döma utav Riksidrottsförbundets lista på medel som inte är tillåtna blir man lätt blind, och t.om ger upp. Där finns helt enkelt inget bra sätt att se ifall ett kosttillskott är dopingklassat eller inte.

Samma dag som diskussionen satte igång var jag fullt igång med att göra något av det. Tekniskt intresserad som jag är lade jag nog mest tyngd på vilka komponenter jag skulle använda. Valen blev följande:

  • DooPHP
  • jQuery
  • mySQL

DooPHP blev valt av den anledningen att det är väldigt komplett, men ändå förvånansvärt snabbt och enkelt att använda.
jQuery för enkelheten med JavaScript och dynamiska webbsidor.
mySQL var lika enkelt att välja, jag behöver bara en enkel tabell med korsreferenser. sqlite hade säkert funkat, men DooPHP har grymt stöd för CRUD och tabellrelationer, som inte verkade vara helt stött med sqlite.

Så, jag satte mig ner och började skrida till verket. Efter några timmar har jag en sida uppe som ligger på http://dopingkollen.se.

Dopingkollen är en kollaborativ sida där alla kan söka, ändra och lägga till produkter. Det som behövs är produktens titel samt dess innehållsförteckning. När produkten finns i databasen jämförs den direkt med RF’s lista och ger information ifall produkten gick igenom eller inte.

Enkelt och smidigt, men designen behöver jobbas på, och det gör jag :) .

Förutom sidan i sigsjälv är där ett API, se http://dopingkollen.se/api, gjort i REST + JSON, för enkel och bandbreddssparande implementering.

Så, nästa steg är att gå igång sidan i sin enklaste form, vara nöjd med designen. Därefter blir det ett nytt spännande projekt som jag tänkte låta vara Open Source, en Android app som implementerar zxing, där man kan använda sin mobilkamera för att skanna en EAN-kod och därefter får resultatet direkt i luren när man står i affären och ska bestämma sig för vilket kosttillskott man funderar på att köpa.

 

 


augusti 28th, 2011  



Goals of 2011

Linux, monotouch, Open source, Programmering 0 Comment »

Haha, just read my old post regarding the goals I had set in 2010. Did any of them come true? – No.

This is how it went:

#1 MonoTouch app
I did start an iPhone application with MonoTouch, but the API for the application is was developing on never got completed so it just died. Would’ve been a great app that’s for sure

#2 Payson drupal module.
Also got started, even got quite far actually, but my leaving of the drupal site I was part of (linuxportalen.se) resulted in a non-complete code. Besides, I have a shallow memory that there were some problems with drupal when it came to directly hook into POST parameters, which were needed by the Payson API. When i think about it I should’ve just made a hacky php that connected to the database with the proper result, but if I’m not mistaken mind was set to do it ”the proper” way, which resulted in a no go.

#3 Community site based on Django
Ah, i really loved python back in early 2010, and I still do, but when I did some research I found tornado server of better use, as I started to more and more like to writer proper API’s, instead of views with hooks of code.

I stopped with the Django project after some time, got back to PHP, created a small framework and started developing the new community site, which also kind of died along with my interest in the Swedish Linux community (yeah, it was meant to replace linuxportalen) whom were too much interested of internal conflicts plus distro war.

But, through the year I looked up some different Web frameworks for PHP, and I found DooPHP, a wonderful and fast framework which is easy to learn and use. There’s a small project going on there, without a release date though, just something I do when I’m bored.

So to sum it up, none of my plans happened with the spare time I had part from my ordinary job, but it’s ok, none of them were too important, even though it looked like it when I think back about it.

 

Goals of 2011
Ha ha, right, I won’t set up any goals this year. I spend far too little time in front of the computer when I’m not working and the truth is, there are other things in life far more important to cherish and enjoy besides techie stuff. But hey, do I find something not too big and fun, I’ll probably do it :-) .

Take care,
Marcus


augusti 15th, 2011  



2010 – Goals for the year

Linux, monotouch, Programmering 2 Comments »

I didn’t make any new year promise to myself. Mostly because there’s nothing more broken than a promise made when welcoming the new year. So, instead of making promises, I’ve made goals that i’ll try to complete and deliver.

#1 – My first iPhone application released

A couple of months ago I beta tested MonoTouch, the .NET framework for the iPhone. It’s a great tool for all of us who doesn’t want to learn Objective-C. After some testing I started to do some actual work for an application. It still needs  more work to be functional but at least I have something to go on. I all goes well this will be done somewhat in April.

#2 – Payson Drupal Module

This one is a bit disturbing and embarrasing. For a long time I’ve wanted to make this module for Drupal where you, as a user have the possibility to sponsor sites by paying a small amount of cash using paysons money transaction system. I like Payson, and it really deserves more focus :) . Hopefulle this will come handy to Drupal site administrators. Hopefully this will can be expected in fall of 2010.

#3 – Community Site based on Django

The Swedish Community has for a long time lacked a good community web site for tracking one of the finest things with open source – The great open project that makes whatever disitribution worthy of. It can be all from background search engines like beagle to music players like Listen. All small components that makes the linux experience that great! This should be expected in late 2010.

That’s the three prioritized goals that I have as it is right now. I’ll end this post now to get started :) .

See you!
/Marcus


januari 1st, 2010  
Tags: django, drupal, iphone, monotouch, php, python



Getting Drupal Modules using Python

Linux, Programmering 0 Comment »

A good friend of mine wrote yesterday a small python script that allows the user to search and download Drupal modules directly via the official ftp.
This was made since it is quite boring/irritating to first browse through the module page on drupal.org and then copy the link to a shell where you download the module you want on your web server.

Instead, Jonas (that’s my friends name, btw) wrote this program that directly scans through the drupal module directory on the ftp and returns the output in a shell where the user just enter the choice that he/she wants. Example:

jonas@thinkpad61:~$ ./idm.py hello
Found 32436 files!
[0] hellomobile-5.x-1.0.tar.gz
[1] hellomobile-5.x-1.1.tar.gz
[2] hellomobile-5.x-1.x-dev.tar.gz
[3] hellotxt-6.x-1.x-dev.tar.gz
Which module do you want to download? 1
Ok, lets get hellomobile-5.x-1.1.tar.gz
jonas@thinkpad61:~$ ls -l hellomobile-5.x-1.1.tar.gz
-rw-r--r-- 1 jonas jonas 824473 2009-10-22 22:34 hellomobile-5.x-1.1.tar.gz

I believe that this is quite usefull and interesting. But, as Jonas mentions in this post. It does not contain the functions that you might need, such as: version filter and dev filter. Meaning that you don’t want to see results for drupal 5 if you are running six. Nor do you want to use developer packages when you are in a critical installation.

I had some time so I made some improvements on the original:

tomburk@linux-e9bm:~> python idm-mf.py --help
Usage: idm-mf.py [options]

Options:
-h, --help            show this help message and exit
-f version, --filter=version
Filter the results in version numbers.
-d, --dev             Show developer packages

This allows the user to filter between the version, of course ”all” can be applied, if one wants to show all the results. Plus, It’s possible to toggle between showing the developer packages or not.

Final result:

tomburk@linux-e9bm:~> python idm-mf.py -f 5 hello
Found a total of 32451 files!
Files containing "hello"
 Based on filter: 5
  Not showing developer packages
[0] hellomobile-5.x-1.0.tar.gz
[1] hellomobile-5.x-1.1.tar.gz
Which module do you want to download? 1
Ok, lets get hellomobile-5.x-1.1.tar.gz
tomburk@linux-e9bm:~> ls -s hellomobile-5.x-1.1.tar.gz
812 hellomobile-5.x-1.1.tar.gz

The file is available here: http://marcusfollrud.net/wp-content/idm-mf.py
Or at github: http://github.com/marcusfollrud/idm
See you!

A small update

2009-10-24 – Added support for multiple file download, Available on both github and in wp-content


oktober 23rd, 2009  
Tags: drupal, modules, python



#MonoTouch how to – Drag and Drop Image

monotouch, Programmering 4 Comments »

My blog posts are commonly in Swedish, but since this might interest users outside the borders of Sweden I decided to write this post in English.

Today, I’ll show how easy it is to Drag an Image around the screen using MonoTouch. Bear with me though, it’s my first how to :) .

It’s actually really simple, and you won’t need the Interface Builder.

What we need to do is to create an UIImageView class that overrides the functions TouchesBegan, TouchesMoved and TouchesEnded. It’s looking like this:

	public class myDraggableImage : UIImageView {

		//Store locations for remembering the last positions, and counting the future ones.
		PointF Location;
		PointF StartLocation;

		bool haveBeenTouchedOnce = false;

		public myDraggableImage ( RectangleF frame ){

					//Set the position of the frame with RectangleF (Replacement of CGRectangle)
					this.Frame = frame;
					StartLocation = this.Frame.Location;
		}

		//This event occurs when you just touch the object
		public override void TouchesBegan (MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
		{
			Console.WriteLine("Touched the object");
			Location = this.Frame.Location;

			var touch = (UITouch) e.TouchesForView (this).AnyObject;
			var bounds = Bounds;

			StartLocation = touch.LocationInView(this);
			this.Frame = new RectangleF(Location,bounds.Size);

		}
		//This event occurs when you drag it around
		public override void TouchesMoved (MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
		{
			Console.WriteLine("Dragged the object");
			var bounds = Bounds;
			var touch = (UITouch) e.TouchesForView (this).AnyObject;

			//Always refer to the StartLocation of the object that you've been dragging.
			Location.X += touch.LocationInView(this).X - StartLocation.X;
			Location.Y += touch.LocationInView(this).Y - StartLocation.Y;

			this.Frame = new RectangleF(Location,bounds.Size);

			haveBeenTouchedOnce = true;
		}

		public override void TouchesEnded (MonoTouch.Foundation.NSSet touches, MonoTouch.UIKit.UIEvent e)
		{
			StartLocation = Location;
		}

	}

What’s being done here is that as soon as we Touch the object it will run ”TouchesBegan” to start keeping track of the Object. And when we are moving it around, it constantly calls ”TouchesMoved” where we are updating the position of the UIImageView on the screen.

When you’ve implemented the class class in your project, all you need to do is to create the object within ”public override bool FinishedLaunching”.
It can for instance look like this:

myDraggableImage img = new myDraggableImage(new RectangleF(64,64,64,64));
			img.UserInteractionEnabled = true;
			img.BackgroundColor = UIColor.Green;
			img.Hidden = false;

			window.AddSubview(img);

The result will be a UIImageView that can be dragged around the screen.


september 23rd, 2009  
Tags: c#, monotouch, UIImageView



MonoTouch trial

Programmering 0 Comment »
MonoTouch

MonoTouch

Ville bara informera för er som missat att MonoTouch numera finns som testversion, för den som vill testa innan köp.

Du kommer att tillåtas att använda MonoTouch fullt ut, och simulera programmet det på din Mac. Vill du däremot testa på din telefon måste du köpa en licens.

Detta är givetvis väldigt bra, för den som vill testa innan köp.

Du laddar ner trial versionen här: http://monotouch.net/DownloadTrial

Detta är perfekt för den som inte har 3010 SEK att spendera på ett projekt man inte är säker på att använda seriöst!

Det känns bra när ett Arbetsteam lyssnar på request de får, och tar till sig det direkt, istället för att komma med en lösning 6 månader senare. Men åandrasidan är det ”open source” människor som skapat det, så man förstår entusiasmen :-)

Härmed avslutas mitt lunchinlägg!

-m


september 16th, 2009  
Tags: c#, monotouch, novell, testversion, trial



MonoTouch släppt

Programmering 0 Comment »
MonoTouch Box. (C) Novell

MonoTouch Box. (C) Novell

Idag är det officiellt. MonoTouch, API:et som låter dig programmera .NET-applikationer till din iPhone är släppt.

Inte nog med att du kan använda .NET API:er direkt i ditt program. Där är även Bindings till Objective-C biblioteken, för att kunna maximera din utveckling på iPhone.

Även om jag personligen inte har hunnit programmera något vidare själv har jag följt mailinglistan, och de som testat är mycket nöjda med produkten. De är mer eller mindre nöjda med precis allt, utom prislappen förstås.

Prislappen hamnar på 3010 SEK för enskild användare. Något som förmodligen kommer utesluta de som vill göra alla de populära småprogrammen. Novell verkar ha lagt sitt fokus på seriösa företag som vill åstadkomma mycket med sin kod, och som är beredda att betala för att återanvända den kunskap som redan finns, dvs slippa lära sig Objective-C.

Personligen har jag inte bestämt mig för vad jag tycker om priset. Många har blivit upprörda, medans andra är nöjda med priset och anser att arbetet som utvecklarna har lagt ner på detta projekt gör att prislappen är helt acceptabel.

Jag ser det mer som en positioneringssak. Jag kan tycka att priset är OK för ett företag, men inte för en hobbyutvecklare som vill tjäna lite snabba pengar. Fler kunder, kräver givetvis mer support, vilket är mer utgifter för Novell. Genom att höja priset till vad det är sållar man säkerligen bort de som egentligen inte kan, men tror sig kunna och fokuserar på de personer som verkligen vill. Detta ger givetvis mindre support för Novell, vilket de tjänar pengar på.

Jag tror att om man sänker priset för lågt på ett paket som detta kommer det att kosta mer än vad det kommer gynna, och jag tror Novell är på samma spår de också.
Jag tror med andra ord att det är ett strategiskt beslut, och inte ett pengagirigt.

Nu när jag granskar vad jag själv analyserat fram från texten ovan får jag nog ändå säga att det är ett pris som är helt OK. Jag är nöjd.

Ta en kik på deras hemsida: http://monotouch.net

Beställ här

Tillbaka till min renovering :) .
Cu


september 14th, 2009  
Tags: c#, monotouch, novell



Wie, jag kom med!

Open source, Programmering 0 Comment »

Häromdagen ansökte jag till MonoTouchprojektet eftersom jag fann det väldigt intressant att utveckla med. Och de snälla människorna gav mig beta access till projektet!

Skall genast testa det och ge det kommentarer, när jag har något. Men testning kan nog inte bli förräns på söndag. Om tio minuter ska vi på födelsedagsevenemang och imorgon skall vi hjälpa min syster med fästman att flytta.

Värt att notera är att MonoTouch kommer bli en kommersiell utgåva, enligt Miguel:

Commersial

För mig är detta helt ok, jag kan tänka mig att det måste vara ett kostsamt avtal med apple för att få lov att göra såhär. Mono i sigsjälvt är ju öppet, och det tycker jag är viktigast!

Jag återkommer som sagt, så fort jag har lite kod att bidra med :) .

Tills vidare refererar jag till monotouch.info och detta inlägg:

http://conceptdev.blogspot.com/2009/09/initiate-call-with-monotouch.html

Go kväll!
Marcus


september 4th, 2009  
Tags: beta, c#, monotouch



Veckans intressanta: MonoTouch

Programmering 0 Comment »

Läste ett blogginlägg från mr Miguel De Icaza som berättar lite grann om MonoTouch, som är ett ramverk för att koda c# till iphone. Verkligen smart!

Det enda som är lite dåligt är  att det inte är open source. Men det är åtminståne baserat på Mono, tror jag. Och mono är ju open source.

Jag är lite glad för detta för Objective C som är standardutvecklingsspråk känns otroligt jobbigt att arbeta i.

Som tur är har jag en MacMini, som förnärvarande arbetar som MediaMac. Dvs, bara en snygg station att kolla på Dvd på! Men nu är jag lite sugen på att installera Xcode och Monodevelop och sätta igång och koda lite till min iphone. Jag får se hur det blir.


september 2nd, 2009  
Tags: apple, c#, iphone, mac, macmini, mono, monotouch, Programmering, youtube



Previous Entries
  • Kategorier

    • Linux
    • monotouch
    • Open source
    • Planet
    • Privat
    • Programmering
    • Spel
  • Arkiv

    • januari 2012
    • september 2011
    • augusti 2011
    • januari 2010
    • december 2009
    • november 2009
    • oktober 2009
    • september 2009
    • augusti 2009
    • juli 2009
  • Etiketter

    2.6.30 16f690 Andjelka ANSI C apparmor apple axis biltema blommor c# curl debian despotify django drupal inaktivitet iphone kde Linux linux mint liseberg mono monotouch novell Open source php pic pic16f690 plasma plasmoid Programmering pump pykde pyqt python qt sdcc sommarstuga spotify spytify vatten vattna blommor virtualbox wordpress youtube
Copyright © 2012 Marcus Follrud
XHTML CSS Logga in