Thursday, 17 October 2013

2. Traffic Calming Part I – Donaldson & Stevens

“He was 'found dead' this morning at 08:15”

“Who by?”

“His heart monitoring software – it alerted the local hospital and a couple of medics were dispatched arriving at approximately 08:22; they confirmed that the heart had stopped.”

“So was he resuscitated?”

“Yes – sort of, there was a miss-understanding concerning the diagnosis which led to the victim being resuscitated and subsequently lost”

“Go on...”

“On arrival the medics found that the victim's pacemaker was malfunctioning and did not provide the boost required to restart his heart. In these cases pacemakers can normally be induced to restart the heart without any surgery; this procedure was carried out and the heart appeared to start momentarily, along with the victims breathing through ventilation”

“Which didn't last long, I presume – I think I can see where this is going...”

“Yes – it was short lived; as was a brief moment of consciousness for the victim”

“Can we stop using the words 'the victim' it's taking too long – what was his name?”

“Karl Bernahrdsson”

“Interesting – go on, let's here the grand finale”

“During consciousness the deceased... Karl Bernahrdsson...”

“For god's sake...”

“Attempted to communicate with the medics – he was recorded as saying, 'shot' whilst seemingly attempting to point to his chest”

“Implying he thought he was shot?”

“I don't know, sir”2004-10-15 006

“You know I don't like that – Ow, my damn hand... why the hell is it hurting – that never happens”

“What don't you like?”

“That 'sir' business...”

There was a long pause.

“Well?”, Donaldson looked up from his sketch pad waiting for more...

“You want me to go on?”

“Well of course I do – do you think I'm just going to sit here and wait for the world to go by when you've just told me something needs to be fixed?”, no reaction, “Let's take a quick look at the video feed – I want to check the... flat, house whatever it is...”

“A flat sir, in the Oakland Village”

“What floor”, Donaldson span his chair round and pulled himself towards his work desk,

“241”

“Let's take a look; for a supposedly tech-free society they do like their gadgets... Yes – is this a glasses feed or an implant?”

“I'd guess an 'bio-enhancement', sir, given the poor colour quality...”

“It's clear as a bell apart from the colour – so, I've got his last moments right here – drinking coffee after coffee...”, Donaldon fast forwarded the video feed,

“...he must have been dehydrated; ...or felt like he was... looking for something... remote control for the pacemaker perhaps – yep, bingo, there it is. Nope – not interested in that – different ideas? Hmmm – seems to be looking for... his watch?”

“He's collapsing there...”

“Yes – not sure he's thinking too much about calling someone...”

“Maybe he thought his pacemaker would let somebody know”

“Maybe – but I'm not sure it's a good idea to rely on it... look, there, he's gone for his computer pad now; watch not good enough for you, eh?”

“I suppose not – what's he doing?”

“A signal diagnostic...”

The feed stopped; Donaldson slowly turned his chair in Stevens' direction. They smiled at each other.

“I don't suppose you'd ever consider testing the intensity of signal noise as you were taking your last breaths, would you...”

“Not sure sir, not yet taken my last breaths as far as I recall...”

“Oh god... OK – drop the policeman façade, it was a crap idea anyway”

“Thank god for that... it was annoying the hell out of me, sir...”

2004-10-15 009“Very funny... Did anyone want him dead?”

“Possibly – he led the review team for work processes at Oakland and Silversand; basically he attempted to find ways of reducing the manual labour”

“So we have a list of those that prefer not to have their day to day lives reviewed from above?”

“Unlikely that they were directly involved, sir.”

“Yes – it seemed unlikely that they would kill somebody for that... I presume we're talking another round of over excited egos?”

“Well, there's been increased access to the Oakland communications hub.”

“Internal or external?”

“Both actually, although most of the 'work' seems to have been carried out on the internal node”

“Great. Is there enough power to injure somebody with the internal node wireless system?”

“No – well, perhaps...”

“'No, perhaps?' What sort of answer is that?”

“Well they're trialling a new system at Oakland – similar to the systems we use on the external hubs”

“Don't tell me they've boosted their power supply enough to cause someone's pacemaker to backfire? Open and shut case!”

“Not exactly, sir, Oakland has, as you know, been developed as a place of tranquillity – something akin to being in the countryside; it has various flora and fauna planted throughout all it's floors – with the central atrium containing a sort of 'vertically planted forest' – if that makes sense to you?”

“Not really – but what was the point”

“It was considered that some occupants who resist the temptation to use technology in their day to day lives might want to live in a substantially electromagnetic wave free environment”

“Yes – and so...?”

“And so systems were developed to cancel out the electromagnetic radiation that was either man made or otherwise”

“I hope they drew the line at sun-light?”

“Yes, yes – of course it was targeted primarily at lower frequencies such as radio and microwave – but also there were attempts in the pipeline to calm x-ray and gamma ray frequencies as well.”

“Sounds like a formidable idea – calm those frequencies down and we can all live quietly and happily until somebody accidentally fails to cancel and through some slip of the technology enhances those little old gamma rays...”

“Yes – sorry about that sir”

“Don't apologise it's not your fault is it?”

“No sir.”

“Oh god – back to the policeman impersonation. Go on...”

“No X-ray or gamma ray cancellation has been attempted.”

“Good – so at least we can cross off radioactive radiation as a cause of death”

“Yes sir... but, not entirely, perhaps.”

“Please do go on – you sound like you've found the solution already.”

“I think I may have done – although I'm not sure what the course of action might be. The electromagnetic noise cancelling works much the same way as headphone noise cancelling products. The system listens for electromagnetic waves and, in order to 'calm' them an equal and opposite wave is created to cancel the original wave's effect. There are a number of problems to this compared with the rather simplistic sound cancelling solutions; number 1: the electromagnetic waves...”, Donaldson winced with the repetition,

“..sorry sir – I'll refer to them as radio waves from now on – radio waves operate in many 'planes' and in some instances can even be 'twisted' if the transmitter is rotating, for instance. Each signal that is received, therefore, must be understood in amplitude as well as orientation and direction (as attempting to calm the frequency back towards the originating transmitter of a twisted signal will require a counter rotation or the calmer's transmission antenna).”

“...is this level of detail required Stevens?”2004-10-15 032

“I think so sir; anyway, because the nature of calming has additional attributes to sound and is also intended to work within a multi-storey environment in '3D' the reception apparatus is complex as is the transmission apparatus. In addition any calculations required must be pretty much instantaneous as we are dealing with signals travelling at the speed of light.”

“OK, so down to brass tacks as they say – does it work?”

“Yes – mostly.”

“Which bits don't work?”

“Twisted or rotational signals are still not particularly well understood when they interfere with obstacles.”

“That doesn't sound like an answer to me. If it doesn't work could it cause an injury?”

“I think so.”

“Under what circumstances”

“Part of the systems' proposed requirements were to aid in the cancellation of radio 'hotspots' brought about by independently run electronic systems throughout the home, whilst still allowing through some wireless signals that were deemed 'required' for emergency systems. Hot spots were sometimes known to be created due to refraction and reflection of radio or micro waves around the building – much in the same way that light is reflected and refracted as it travels through water or glass, longer wavelengths such as microwave and radio waves are affected as they pass through walls and, say, people. Occasionally, completely separate signals would converge in a space and 'amplify' one another. In most unusual circumstances plastics were known to melt in some steel structured buildings that focused radio signals inappropriately.”

“Frightening – please give me a list of the problem areas so that I can avoid them.”

“There are none – nowadays sir, due to various building regulations and calming systems such as the new one at Oaklands. It uses an array of signal receivers and transmitters to ensure that wireless communications are sent to only where they are needed and are mostly cancelled out from those areas where they are not. The 'cancelling' is only in the Oakland facility, however, Silversand and Upton are still 'au naturale', if you will...”

“OK – so what you're saying is that the radio calming system may have a) been tampered with to produce an attack on a member of the Oakland community or b) is failing to work correctly (possibly in the realm of 'rotational signals') and, perhaps, some interference from a pacemaker caused a 'pocket' of high energy that caused an accidental death?”

“That sounds like a reasonable assessment sir”

“OK, good... that sounds like we have a case to work with... I'll monitor it.”

“Good – thank you sir.”

“Anything else?”

“No – that's all for the moment.”

“I'll call you.”

Sunday, 13 October 2013

1. A Wide Open Space (We’ve Started)…

“It's like being used over and over again to do the same thing... I hate it.”
“How long has it been going on for?”
“About ten or fifteen years, depending on how you think about it.”
“And how do you think about it?”
“I try not to – if I do it feels like my life is just an excuse to waste time.”DSC02733
He stopped for a moment, took a cigarette from the pack on the table and started searching for a light.
“Have you got a light?”
She smiled: “I thought you were going to ask me something else...”
“I can do – just as soon as I light this cigarette”, she threw him her lighter; he took a glance at it before quickly lifting it to light up.
“Starfish – I like it... on a beach, I presume.”
“I don't know – it just seemed to make me happy when I saw it”
“Is there much happiness in your life?”
“That's what I thought you were going to ask me; before, I mean...”
Isaac placed the lighter onto the table in front of them, equidistantly between their two cups of coffee, starfish side up:
“So you're intelligent; you can quickly see the rules of life and see what might happen next”
“It's not interesting though”
“Perhaps, Serena, the interest comes from understanding what to do with the talent”
“I only ever think of bad things to do – I get angry with people...”
“The situation...”
“What?”
“It's better to get annoyed – or angry as you put it – with the situation, rather than with a person or persons.”, he turned the lighter over hiding the image.
“What difference does it make?”
“It makes a big difference – it can be the difference between doing something useful with your talent and getting annoyed with everybody and yourself. Try it... if you like.”
“OK – I might do... once I get 'annoyed' I find myself less likely to 'help'.”
He paused and looked at her, trying to gauge whether she was still thinking – she was DSC02738looking down at her hands. The odd car drifted by, another drag on the cigarette and he drank some of the cold black coffee that had been untouched on the table for about 10 minutes. He winced:
“I don't know why I drink coffee – I'm not convinced I actually like it.”
“You're just the same, aren't you...”, not a question – more of a statement, a gradual realisation, “you're trapped too – aren't you?”
“If you mean I'm trapped by my romantic 1950's Hollywood vision of the world and that I believe that at moments like these I should smoke a cigarette and drink black coffee whilst I talk to my beautiful ex-girlfriend then, yes, I'm trapped... I drink coffee because I think it fits the part I'm playing.”
“Why do you play it if you don't like it?”
“It's not that much of a hardship to drink black coffee, smoke too many cigarettes and spend some time with the only girl I ever loved...”
“Stop!”
“I'm afraid you can't switch me off – that bit of my life was real – I did love you. It's the rest of it that seems a bit mad... otherwise I'm just hanging around waiting for the rest of my consciousness to return.”
DSC02737“Sorry – I didn't mean to do that. I mean, I didn't mean to say 'stop'.”
“It's OK, no harm done. I'm in a wide open space...”
She smiled – and shook a little with a suggestion of laughter; by way of explanation:
“Just a song I used to like – in fact I still like it... reminds me of long drives...”
“Sounds good. So how does life feel now?”
“OK. Thanks. I know you've helped – although I'm not quite sure how.”
“Nor am I. It might be that I haven't.”
“Well thanks anyway. Thanks for your time.”
He stood and stretched, arching his back: “It's always my pleasure. ...and if you feel the urge to 'put out' as our American cousins would put it – do get in touch.”
“You're starting to sound like a film now. I don't like it...”
“Too late. You're stuck with it – we've started.”

Monday, 13 May 2013

Group by Months/Weeks

Beautiful bit of code for counting valid fields and grouping the results in month/week chunks – simply replace the %%INTERVAL%% with either WEEK or MONTH (or any other valid DATEADD identifier, for that matter) and specify the table and %%DateField%% you are interested in:

    ;WITH d(d) AS 
(
SELECT DATEADD(%%INTERVAL%%, n, DATEADD(%%INTERVAL%%,
DATEDIFF(%%INTERVAL%%, 0, @minDate), 0))
FROM ( SELECT TOP (DATEDIFF(%%INTERVAL%%, @minDate, @maxDate) + 1)
n = ROW_NUMBER() OVER (ORDER BY [object_id]) - 1
FROM sys.all_objects ORDER BY [object_id] ) AS n
)
SELECT
--COALESCE(op.Id, @ID) AS ID,
d.d AS Date,
count(op.%%DateField%%) AS CountOfItems
FROM
d LEFT OUTER JOIN
(select * FROM Ops o WHERE
o.Operation_Project = @Project_ID or @Project_ID = 1) op
ON op.%%DateField%% >= d.d AND
op.%%DateField%% < DATEADD(%%INTERVAL%%, 1, d.d)
GROUP BY
--op.Operation_Project,
d.d
HAVING
d.d < (SELECT MAX(o.%%DateField%%) FROM Ops o
WHERE o.Id = @Project_ID or @Project_ID = 1)
ORDER BY
d.d