Failed to put message to the backout queue Message broker - ibm-mq

I have developed a flow which picks up a message from MQInput, Inserts it into the DB by calling a stored procedure and then dumps the message to another queue. The message is in XMLNSC.
The flow was in running state for 2 months but now I am getting exceptions of weird issues.
3 days back I got this kind of exception:
(0x01000000:Name):RecoverableException = (
(0x03000000:NameValue):File = '/build/slot1/S900_P/src/DataFlowEngine/MessageServices/ImbDataFlowNode.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 1153 (INTEGER)
(0x03000000:NameValue):Function = 'ImbDataFlowNode::createExceptionList' (CHARACTER)
(0x03000000:NameValue):Type = 'ComIbmComputeNode' (CHARACTER)
(0x03000000:NameValue):Name = 'SiebelBOQManagement#FCMComposite_1_2' (CHARACTER)
(0x03000000:NameValue):Label = 'SiebelBOQManagement.Compute' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPmsgs' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 2230 (INTEGER)
(0x03000000:NameValue):Text = 'Node throwing exception' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 14 (INTEGER)
(0x03000000:NameValue):Text = 'SiebelBOQManagement.Compute' (CHARACTER)
)
(0x01000000:Name ):RecoverableException = (
(0x03000000:NameValue):File = '/build/slot1/S900_P/src/DataFlowEngine/ImbRdl/ImbRdlStatementGroup.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 666 (INTEGER)
(0x03000000:NameValue):Function = 'SqlStatementGroup::execute' (CHARACTER)
(0x03000000:NameValue):Type = 'ImbESQLManager' (CHARACTER)
(0x03000000:NameValue):Name = 'ImbESQLManager' (CHARACTER)
(0x03000000:NameValue):Label = 'ImbESQLManager' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPmsgs' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 2488 (INTEGER)
(0x03000000:NameValue):Text = 'Error detected, rethrowing' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = '.SiebelBOQManagement_Compute.Main' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = '20.3' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'LOGDEBUG(CAST(startTime AS CHARACTER) || '|SiebelBOQManagement|Request|' || CAST(ASBITSTREAM(InputRoot.XMLNSC) AS CHARACTER CCSID 1208), 'Siebel');' (CHARACTER)
)
(0x01000000:Name ):RecoverableException = (
(0x03000000:NameValue):File = '/build/slot1/S900_P/src/DataFlowEngine/ImbRdl/ImbRdlRoutine.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 1450 (INTEGER)
(0x03000000:NameValue):Function = 'SqlRoutine::invoke' (CHARACTER)
(0x03000000:NameValue):Type = 'ImbESQLManager' (CHARACTER)
(0x03000000:NameValue):Name = 'ImbESQLManager' (CHARACTER)
(0x03000000:NameValue):Label = 'ImbESQLManager' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPmsgs' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 2934 (INTEGER)
(0x03000000:NameValue):Text = 'Error occured in procedure' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'LOGDEBUG' (CHARACTER)
)
(0x01000000:Name ):RecoverableException = (
(0x03000000:NameValue):File = '/build/slot1/S900_P/src/DataFlowEngine/ImbRdl/ImbRdlExternalJava.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 1458 (INTEGER)
(0x03000000:NameValue):Function = 'SqlExternalJavaMethod::executeJavaMethod' (CHARACTER)
(0x03000000:NameValue):Type = '' (CHARACTER)
(0x03000000:NameValue):Name = '' (CHARACTER)
(0x03000000:NameValue):Label = '' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPmsgs' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 2919 (INTEGER)
(0x03000000:NameValue):Text = 'The following error occurred during execution of an Java Method call' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = '.LOGDEBUG' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = '1.1' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'com.ufone.utility.ProvLogger.LogDebug' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = ''1435077650205|SiebelBOQManagement|Request|<Message MessageId="1-7XUQQC" IntObjectName="PTCL Order Entry EAI IO" MessageType="Integration Object" IntObjectFormat="Siebel Hierarchical">.......</Message>
)
(0x01000000:Name ):RecoverableException = (
(0x03000000:NameValue):File = '/build/slot1/S900_P/src/DataFlowEngine/ImbRdl/ImbRdlExternalJava.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 1339 (INTEGER)
(0x03000000:NameValue):Function = 'SqlExternalJavaMethod::executeJavaMethod' (CHARACTER)
(0x03000000:NameValue):Type = '' (CHARACTER)
(0x03000000:NameValue):Name = '' (CHARACTER)
(0x03000000:NameValue):Label = '' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPmsgs' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 2917 (INTEGER)
(0x03000000:NameValue):Text = 'Java Exception calling CallStaticVoidMethodA.' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'com.ufone.utility.ProvLogger.LogDebug' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'java.lang.OutOfMemoryError: Java heap space' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = '' (CHARACTER)
)
)
)
)
When i got this error I knew the memory is full and i stopped the flow. A day later i couldnt find any specific issue in the code and started the flow again.
Mind you that the XML which i am logging is 6000 lines long.
Yesterday I got exceptions in my trace as:
(0x01000000:Name):RecoverableException = (
(0x03000000:NameValue):File = '/build/slot1/S900_P/src/DataFlowEngine/MQLibrary/linklib/ImbMqInputNode.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 2528 (INTEGER)
(0x03000000:NameValue):Function = 'ImbCommonInputNode::eligibleForBackout' (CHARACTER)
(0x03000000:NameValue):Type = 'ComIbmMQInputNode' (CHARACTER)
(0x03000000:NameValue):Name = 'SiebelBOQManagement#FCMComposite_1_6' (CHARACTER)
(0x03000000:NameValue):Label = 'SiebelBOQManagement.MQ Input' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPmsgs' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 2613 (INTEGER)
(0x03000000:NameValue):Text = 'Failed to put message to the back out queue' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'SYSTEM.DEAD.LETTER.QUEUE' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 2 (INTEGER)
(0x03000000:NameValue):Text = '2' (CHARACTER)
)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 2 (INTEGER)
(0x03000000:NameValue):Text = '2056' (CHARACTER)
)
)
)
I am unable to find the root cause. As for a month the Debug procedure was working fine and it wrote the whole XML in the logs and now the flow is giving me abnormal behavior. Also BOQ's are configured for both the input and output queues.

From the above error, there are two possibilities which caused this error.
QMGR file system might be full. Please check /var/mqm file system. If you don't find any issues with this file system, please refere 2nd point
Size of your queue file might be larger than the user file limit size. Please check your file limit size using ulimit -f. And, compare it with your queue file size. I suspect this might be causing you the issue. If so, you can always increase your file system for larger queues using 'ulimit -f 4194302' which is 2GB.

Related

Get Windows 32-bit formatted Time/Date in PowerShell

Is there a PowerShell command for retrieving the current datetime as a value encoded in the Windows C Runtime 32-Bit Time/Date Format?
I am not aware of an already existing function for that. You can do it manually like this:
$date = Get-Date
[uint16]$encodedTime = (((($date.Hour) -shl 6) + $date.Minute) -shl 5) + $date.Second / 2
[uint16]$encodedDate = (((($date.Year - 1980) -shl 4) + $date.Month) -shl 5) + $date.Day
You can combine these values further, if needed:
[uint32]$encodedTimeDate = $encodedTime -shl 16 + $encodedDate
[uint32]$encodedDateTime = $encodedDate -shl 16 + $encodedTime
To complement stackprotector's excellent answer, I used his code to create two helper functions to convert to and -from a dos datetime value:
function ConvertTo-DosDateTime {
[CmdletBinding()]
param (
[Parameter(Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[DateTime]$Date = (Get-Date)
)
# seconds are stored divided by 2
[uint16]$encodedTime = (((($Date.Hour) -shl 6) + $Date.Minute) -shl 5) + ($Date.Second -shr 1)
[uint16]$encodedDate = (((($Date.Year - 1980) -shl 4) + $Date.Month) -shl 5) + $Date.Day
([uint32]$encodedDate -shl 16) + $encodedTime
}
function ConvertFrom-DosDateTime {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[uint32]$DosDate
)
# split the 4 bytes into a date and a time part
[uint32]$encodedDate = $DosDate -shr 16
[uint32]$encodedTime = $DosDate -band 0xffff
# shift and mask-off the relevant bits
$day = $encodedDate -band 0x1f # 5 bits (0-4)
$month = ($encodedDate -shr 5) -band 0xf # 4 bits (5-8)
$year = (($encodedDate -shr 9) -band 0x7f) + 1980 # 7 bits (9-15)
# same for the time part
$secs = ($encodedTime -band 0x1f) * 2 # 5 bits (0-4)
$mins = ($encodedTime -shr 5) -band 0x3f # 6 bits (5-10)
$hrs = ($encodedTime -shr 11) -band 0x1f # 5 bits (11-15)
# return as DateTime object
Get-Date -Year $year -Month $month -Day $day -Hour $hrs -Minute $mins -Second $secs -Millisecond 0
}
All credits to stackprotector of course.

function does not return embed discord.py

I have a problem with a function:
In order not to have to rewrite the same 100 strings for each if I decided to create this function that would return the embed but unfortunately it does not return the same.
I have no errors so I don't understand where the problem is
Code function:
def rob_true():
ratm = random.randrange(50, 500)
economy_system[id_other]["wallet"] -= ratm
if economy_system[id_other]["wallet"] < 0:
negative_wallet = economy_system[id_other]["wallet"]
ratm = ratm + negative_wallet
economy_system[id_other]["wallet"] = 0
economy_system[id_author]["wallet"] += ratm
if ratm < 100:
embed = discord.Embed(
title="Rob!",
description=f"Non sei stato molto fortunato.\nHai rubato solo {ratm}€ a {other.name}",
color=0x03c03c
)
embed.set_author(
name=f"{ctx.author.name}",
icon_url=f"{ctx.author.avatar_url}"
)
embed.set_thumbnail(url=ctx.guild.icon_url)
if 100 < ratm < 250:
embed = discord.Embed(
title="Rob!",
description=f"Ti è andata bene!\nHai rubato {ratm}€ a {other.name}",
color=0x03c03c
)
embed.set_author(
name=f"{ctx.author.name}",
icon_url=f"{ctx.author.avatar_url}"
)
embed.set_thumbnail(url=ctx.guild.icon_url)
if 250 < ratm < 450:
embed = discord.Embed(
title="Rob!",
description=f"Hai rubato un'ottima somma!\nHai rubato {ratm}€ a {other.name}",
color=0x03c03c
)
embed.set_author(
name=f"{ctx.author.name}",
icon_url=f"{ctx.author.avatar_url}"
)
embed.set_thumbnail(url=ctx.guild.icon_url)
else:
embed = discord.Embed(
title="Rob!",
description=f"Guarda che fortuna!\nHai rubato {ratm}€ a {other.name}",
color=0x03c03c
)
embed.set_author(
name=f"{ctx.author.name}",
icon_url=f"{ctx.author.avatar_url}"
)
embed.set_thumbnail(url=ctx.guild.icon_url)
return embed
Whole code:
#client.command()
async def rob_(ctx, other: discord.Member=None):
#PRE-INIZIO: Primissime cose che deve fare il comando prima di iniziare, di solito cancellare se si vuole il messaggio del comando.
await ctx.message.delete()
id_author = str(ctx.author.id)
#ERRORI: Settaggio dei vari errori che darà il comando se non viene eseguito perfettamente.
embed = discord.Embed(
color=0xa61022
)
if not other:
embed.set_author(
name="Per favore specifica la persona che vuoi rubare!",
)
await ctx.send(embed=embed, delete_after=10.0)
return
id_other = str(other.id)
if id_author not in economy_system:
embed.set_author(
name=f"{ctx.author.name} prima di accedere a questo comando devi creare un account!"
)
await ctx.send(embed=embed, delete_after=10)
await client.get_command("superdaily").reset_cooldown(ctx)
return
if id_other not in economy_system:
embed.set_author(
name=f"{other.name} non ha un account!"
)
await ctx.send(embed=embed, delete_after=10)
return
#INSERIMENTO: Qui iniziamo a definire le variabili che serviranno al nostro comando
template = [
("1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", 0, 1, 0, 3, 2, 0,)
]
reac1, reac2, reac3, reac4, reac5, reac6, res1, res2, res3, res4, res5, res6 = random.choice(template)
print(reac1, reac2, reac3, reac4, reac5, reac6, res1, res2, res3, res4, res5, res6)
count = 0
value = 0
if res1 == 1:
value1 = reac1
if res2 == 1:
value1 = reac2
if res3 == 1:
value1 = reac3
if res4 == 1:
value1 = reac4
if res5 == 1:
value1 = reac5
if res6 == 1:
value1 = reac6
if res1 == 2:
value2 = reac1
if res2 == 2:
value2 = reac2
if res3 == 2:
value2 = reac3
if res4 == 2:
value2 = reac4
if res5 == 2:
value2 = reac5
if res6 == 2:
value2 = reac6
if res1 == 3:
value3 = reac1
if res2 == 3:
value3 = reac2
if res3 == 3:
value3 = reac3
if res4 == 3:
value3 = reac4
if res5 == 3:
value3 = reac5
if res6 == 3:
value3 = reac6
print(value1, value2, value3)
#USCITA: Da qui tutte il comando verrà eseguito con tutte le azioni che vogliamo, questa parte può essere la più lunga
embed = discord.Embed(
title="Rob!",
description="Per rubare dei soldi bisogna essere veloci senza farsi scoprire!\nCerto non saprai se ruberai tanto o poco ma l'importante è non farsi sgamare!\n\nHai 5 secondi di tempo per cliccare 3 reazione nel seguente ordine scritte su **status**\n__N.B Il tempo partirà non appena lo status ti darà le 3 reazioni__\n**STATUS**: Aggiungendo le reazioni...",
color=0x003399
)
embed.set_author(
name=f"{ctx.author.name}",
icon_url=f"{ctx.author.avatar_url}"
)
embed.set_thumbnail(url=ctx.guild.icon_url)
message = await ctx.send(embed=embed)
await message.add_reaction(reac1)
await message.add_reaction(reac2)
await message.add_reaction(reac3)
await message.add_reaction(reac4)
await message.add_reaction(reac5)
await message.add_reaction(reac6)
embed = discord.Embed(
title="Rob!",
description=f"**STATUS**:\n {value1} **->** {value2} **->** {value3}",
color=0x003399
)
embed.set_author(
name=f"{ctx.author.name}",
icon_url=f"{ctx.author.avatar_url}"
)
embed.set_thumbnail(url=ctx.guild.icon_url)
await message.edit(embed=embed)
def rob_check(reaction, user):
return user == ctx.author and str(reaction.emoji) in [reac1, reac2, reac3, reac4, reac5, reac6]
def rob_true():
#inserted above
#def rob_false()
while True:
try:
reaction, user = await client.wait_for("reaction_add", timeout=5, check=rob_check)
if str(reaction.emoji) == reac1:
count = count + 1
if count == 1:
if res1 == 1:
value = value + 1
else:
await message.delete()
return
if count == 2:
if res1 == 2:
value = value + 1
else:
await message.delete()
return
if count == 3:
if res1 == 3:
rob_true()
return
else:
await message.delete()
return
if str(reaction.emoji) == reac2:
count = count + 1
if count == 1:
if res2 == 1:
value = value + 1
else:
await message.delete()
return
if count == 2:
if res2 == 2:
value = value + 1
else:
await message.delete()
return
if count == 3:
if res2 == 3:
rob_true()
return
else:
await message.delete()
return
if str(reaction.emoji) == reac3:
count = count + 1
if count == 1:
if res3 == 1:
value = value + 1
else:
await message.delete()
return
if count == 2:
if res3 == 2:
value = value + 1
else:
await message.delete()
return
if count == 3:
if res3 == 3:
rob_true()
return
else:
await message.delete()
return
if str(reaction.emoji) == reac4:
count = count + 1
if count == 1:
if res4 == 1:
value = value + 1
else:
await message.delete()
return
if count == 2:
if res4 == 2:
value = value + 1
else:
await message.delete()
return
if count == 3:
if res4 == 3:
if economy_system[id_other]["wallet"] == 0:
embed = discord.Embed(
title="Rob!",
description=f"{other.name} non ha nulla quindi non guadagni nulla!",
color=0xa61022
)
embed.set_author(
name=f"{ctx.author.name}",
icon_url=f"{ctx.author.avatar_url}"
)
embed.set_thumbnail(url=ctx.guild.icon_url)
await message.edit(embed=embed)
return
rob_true()
await ctx.send(embed=embed)
_save()
return
else:
await message.delete()
return
if str(reaction.emoji) == reac5:
count = count + 1
if count == 1:
if res5 == 1:
value = value + 1
else:
await message.delete()
return
if count == 2:
if res5 == 2:
value = value + 1
else:
await message.delete()
return
if count == 3:
if res5 == 3:
rob_true()
return
else:
await message.delete()
return
if str(reaction.emoji) == reac6:
count = count + 1
if count == 1:
if res6 == 1:
value = value + 1
else:
await message.delete()
return
if count == 2:
if res6 == 2:
value = value + 1
else:
await message.delete()
return
if count == 3:
if res6 == 3:
rob_true()
return
else:
await message.delete()
return
except asyncio.TimeoutError:
print("ok")
break
The code is still incomplete for now I was just testing this function and unfortunately it gives me this error.
Is there any way to fix?
N.B I ask this question because I have not found it anywhere and I think it could be useful in the future
It might be because you are only returning the embed, not sending it. So every time you call rob_true(), you need to send it instead, by doing await ctx.send(embed=rob_true()) (in place of when you call rob_true()), which sends the returned embed.

Python3 : unpack requires a bytes object of length 117

I am trying to run script for astronomical algorithm VSOP2013.
but when I running this script, it displays error in line 178
how to solve it?
What's wrong with unpack function?
FYI, the original script is python2, i am using python3
a = self.fmt.unpack(terms.encode())
error: unpack requires a bytes object of length 117
This is my full python3 script, adapted from the original python2 version from http://domenicomustara.blogspot.co.id
# -*- coding: utf-8 -*-
import gmpy2 as gmp
import struct
import ctypes
gmp.get_context().precision=200
def cal2jul(year, month, day, hour=0, minute =0, second=0):
month2 = month
year2 = year
if month2 <= 2:
year2 -= 1
month2 += 12
if (year*10000 + month*100 + day) > 15821015:
a = int(year2/100)
b = 2 - a + int(a/4)
else:
a = 0
b = 0
if year < 0:
c = int((365.25 * year2)-0.75)
else:
c = int(365.25 * year2)
d = int(30.6001 *(month2 + 1))
return b + c + d + day + hour / 24.0 + minute / 1440.0 + second / 86400.0 + 1720994.5
class VSOP2013():
def __init__(self, t, planet, precision=1e-7):
# calculate millennia from J2000
self.JD = t
self.t = gmp.div((t - cal2jul(2000,1,1,12)), 365250.0)
# predefine powers of self.t
self.power = []; self.power.append(gmp.mpfr(1.0)); self.power.append(self.t)
for i in range(2,21):
t = self.power[-1]
self.power.append(gmp.mul(self.t,t))
# choose planet file in a dict
self.planet = planet
self.planets = {'Mercury':'VSOP2013p1.dat',
'Venus' :'VSOP2013p2.dat',
'EMB' :'VSOP2013p3.dat',
'Mars' :'VSOP2013p4.dat',
'Jupiter':'VSOP2013p5.dat',
'Saturn' :'VSOP2013p6.dat',
'Uranus' :'VSOP2013p7.dat',
'Neptune':'VSOP2013p8.dat',
'Pluto' :'VSOP2013p9.dat'}
# VSOP2013 routines precision
self.precision = precision
# lambda coefficients
# l(1,13) : linear part of the mean longitudes of the planets (radian).
# l(14): argument derived from TOP2013 and used for Pluto (radian).
# l(15,17) : linear part of Delaunay lunar arguments D, F, l (radian).
self.l = (
(gmp.mpfr(4.402608631669), gmp.mpfr(26087.90314068555)),
(gmp.mpfr(3.176134461576), gmp.mpfr(10213.28554743445)),
(gmp.mpfr(1.753470369433), gmp.mpfr(6283.075850353215)),
(gmp.mpfr(6.203500014141), gmp.mpfr(3340.612434145457)),
(gmp.mpfr(4.091360003050), gmp.mpfr(1731.170452721855)),
(gmp.mpfr(1.713740719173), gmp.mpfr(1704.450855027201)),
(gmp.mpfr(5.598641292287), gmp.mpfr(1428.948917844273)),
(gmp.mpfr(2.805136360408), gmp.mpfr(1364.756513629990)),
(gmp.mpfr(2.326989734620), gmp.mpfr(1361.923207632842)),
(gmp.mpfr(0.599546107035), gmp.mpfr(529.6909615623250)),
(gmp.mpfr(0.874018510107), gmp.mpfr(213.2990861084880)),
(gmp.mpfr(5.481225395663), gmp.mpfr(74.78165903077800)),
(gmp.mpfr(5.311897933164), gmp.mpfr(38.13297222612500)),
(gmp.mpfr(0.000000000000), gmp.mpfr(0.3595362285049309)),
(gmp.mpfr(5.198466400630), gmp.mpfr(77713.7714481804)),
(gmp.mpfr(1.627905136020), gmp.mpfr(84334.6615717837)),
(gmp.mpfr(2.355555638750), gmp.mpfr(83286.9142477147)))
# planetary frequencies in longitude
self.freqpla = {'Mercury' : gmp.mpfr(0.2608790314068555e5),
'Venus' : gmp.mpfr(0.1021328554743445e5),
'EMB' : gmp.mpfr(0.6283075850353215e4),
'Mars' : gmp.mpfr(0.3340612434145457e4),
'Jupiter' : gmp.mpfr(0.5296909615623250e3),
'Saturn' : gmp.mpfr(0.2132990861084880e3),
'Uranus' : gmp.mpfr(0.7478165903077800e2),
'Neptune' : gmp.mpfr(0.3813297222612500e2),
'Pluto' : gmp.mpfr(0.2533566020437000e2)}
# target variables
self.ax = gmp.mpfr(0.0) # major semiaxis
self.ml = gmp.mpfr(0.0) # mean longitude
self.kp = gmp.mpfr(0.0) # e*cos(perielium longitude)
self.hp = gmp.mpfr(0.0) # e*sin(perielium longitude)
self.qa = gmp.mpfr(0.0) # sin(inclination/2)*cos(ascending node longitude)
self.pa = gmp.mpfr(0.0) # sin(inclination/2)*cos(ascending node longitude)
self.tg_var = {'A':self.ax, 'L':self.ml, 'K':self.kp,
'H':self.hp, 'Q':self.qa, 'P':self.pa }
# eps = (23.d0+26.d0/60.d0+21.41136d0/3600.d0)*dgrad
self.eps = gmp.mpfr((23.0+26.0/60.0+21.411360/3600.0)*gmp.const_pi()/180.0)
self.phi = gmp.mpfr(-0.051880 * gmp.const_pi() / 180.0 / 3600.0)
self.ceps = gmp.cos(self.eps)
self.seps = gmp.sin(self.eps)
self.cphi = gmp.cos(self.phi)
self.sphi = gmp.sin(self.phi)
# rotation of ecliptic -> equatorial rect coords
self.rot = [[self.cphi, -self.sphi*self.ceps, self.sphi*self.seps],
[self.sphi, self.cphi*self.ceps, -self.cphi*self.seps],
[0.0, self.seps, self.ceps ]]
self.fmt = struct.Struct("""6s 3s 3s 3s 3s x 3s 3s 3s 3s 3s x 4s 4s 4s 4s x
6s x 3s 3s 3s 20s x 3s 20s x 3s x""")
self.gmp_ = {
'Mercury' : gmp.mpfr(4.9125474514508118699e-11),
'Venus' : gmp.mpfr(7.2434524861627027000e-10),
'EMB' : gmp.mpfr(8.9970116036316091182e-10),
'Mars' : gmp.mpfr(9.5495351057792580598e-11),
'Jupiter' : gmp.mpfr(2.8253458420837780000e-07),
'Saturn' : gmp.mpfr(8.4597151856806587398e-08),
'Uranus' : gmp.mpfr(1.2920249167819693900e-08),
'Neptune' : gmp.mpfr(1.5243589007842762800e-08),
'Pluto' : gmp.mpfr(2.1886997654259696800e-12)}
self.gmsol = gmp.mpfr(2.9591220836841438269e-04)
self.rgm = gmp.sqrt(self.gmp_[self.planet]+self.gmsol)
# run calculus routine
self.calc()
def __str__(self):
vsop_out = "{:3.13} {:3.13} {:3.13} {:3.13} {:3.13} {:3.13}\n".format(
self.tg_var['A'],
self.tg_var['L'],
self.tg_var['K'],
self.tg_var['H'],
self.tg_var['Q'],
self.tg_var['P'])
vsop_out += "{:3.13} {:3.13} {:3.13} {:3.13} {:3.13} {:3.13}\n".format(
self.ecl[0],
self.ecl[1],
self.ecl[2],
self.ecl[3],
self.ecl[4],
self.ecl[5])
vsop_out += "{:3.13} {:3.13} {:3.13} {:3.13} {:3.13} {:3.13}\n".format(
self.equat[0],
self.equat[1],
self.equat[2],
self.equat[3],
self.equat[4],
self.equat[5])
return vsop_out
def calc(self):
with open(self.planets[self.planet]) as file_in:
terms = []
b = '*'
while b != '':
b = file_in.readline()
if b != '':
if b[:5] == ' VSOP':
header = b.split()
#print header[3], header[7], header[8], self.t**int(header[3])
no_terms = int(header[4])
for i in range(no_terms):
#6x,4i3,1x,5i3,1x,4i4,1x,i6,1x,3i3,2a24
terms = file_in.readline()
# print('terms',terms)
a = self.fmt.unpack(terms.encode())
S = gmp.mul(gmp.mpfr(a[18]),gmp.exp10(int(a[19])))
C = gmp.mul(gmp.mpfr(a[20]),gmp.exp10(int(a[21])))
if gmp.sqrt(S*S+C*C) < self.precision:
break
aa = 0.0; bb = 0.0;
for j in range(1,18):
aa += gmp.mul(gmp.mpfr(a[j]), self.l[j-1][0])
bb += gmp.mul(gmp.mpfr(a[j]), self.l[j-1][1])
arg = aa + bb * self.t
power = int(header[3])
comp = self.power[power] * (S * gmp.sin(arg) + C * gmp.cos(arg))
if header[7] == 'L' and power == 1 and int(a[0]) == 1:
pass
else:
self.tg_var[header[7]] += comp
self.tg_var['L'] = self.tg_var['L'] + self.t * self.freqpla[self.planet]
self.tg_var['L'] = self.tg_var['L'] % (2 * gmp.const_pi())
if self.tg_var['L'] < 0:
self.tg_var['L'] += 2*gmp.const_pi()
print ("Julian date {}".format(self.JD))
file_in.close()
##print self.tg_var
#### def ELLXYZ(self):
xa = self.tg_var['A']
xl = self.tg_var['L']
xk = self.tg_var['K']
xh = self.tg_var['H']
xq = self.tg_var['Q']
xp = self.tg_var['P']
# Computation
xfi = gmp.sqrt(1.0 -xk * xk - xh * xh)
xki = gmp.sqrt(1.0 -xq * xq - xp * xp)
u = 1.0/(1.0 + xfi)
z = complex(xk, xh)
ex = abs(z)
ex2 = ex * ex
ex3 = ex2 * ex
z1 = z.conjugate()
#
gl = xl % (2*gmp.const_pi())
gm = gl - gmp.atan2(xh, xk)
e = gl + (ex - 0.1250 * ex3) * gmp.sin(gm)
e += 0.50 * ex2 * gmp.sin(2.0 * gm)
e += 0.3750 * ex3 * gmp.sin(3.0 * gm)
#
while True:
z2 = complex(0.0, e)
zteta = gmp.exp(z2)
z3 = z1 * zteta
dl = gl - e + z3.imag
rsa = 1.0 - z3.real
e = e + dl / rsa
if abs(dl) < 1e-15:
break
#
z1 = u * z * z3.imag
z2 = gmp.mpc(z1.imag, -z1.real)
zto = (-z+zteta+z2)/rsa
xcw = zto.real
xsw = zto.imag
xm = xp * xcw - xq * xsw
xr = xa * rsa
#
self.ecl = []; self.equ = {}
self.ecl.append(xr * (xcw -2.0 *xp * xm))
self.ecl.append(xr * (xsw +2.0 *xq * xm))
self.ecl.append(-2.0 * xr * xki * xm)
#
xms = xa *(xh + xsw) / xfi
xmc = xa *(xk + xcw) / xfi
xn = self.rgm / xa ** (1.50)
#
self.ecl.append( xn *((2.0 * xp * xp - 1.0) * xms + 2.0 * xp * xq * xmc))
self.ecl.append( xn *((1.0 -2.0 * xq * xq) * xmc -2.0 * xp * xq * xms))
self.ecl.append( 2.0 * xn * xki * (xp * xms + xq * xmc))
# Equatorial rectangular coordinates and velocity
#
#
# --- Computation ------------------------------------------------------
#
self.equat = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
for i in range(3):
for j in range(3):
self.equat[i] = self.equat[i] + self.rot[i][j] * self.ecl[j]
self.equat[i+3] = self.equat[i+3] + self.rot[i][j] * self.ecl[j+3]
if __name__ == '__main__':
for planet in ('Mercury', 'Venus', 'EMB', 'Mars', 'Jupiter',
'Saturn', 'Uranus', 'Neptune', 'Pluto'):
print ("PLANETARY EPHEMERIS VSOP2013 "+ planet + "(TDB)\n"+"""
1/ Elliptic Elements: a (au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - Dynamical Frame J2000
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
""")
init_date = cal2jul(1890,6,26,12)
set_date = init_date
while set_date < init_date + 41000:
v = VSOP2013(set_date, planet)
print (v)
set_date += 4000
Respond comment from Mr.barrycarter,
this is a bit of the result when i print(terms.encode()):
b' 2 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0.6684459764580090 -07 0.3603178002233933 -06\n'
b' 3 0 2 -4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2383757728520679 -07 0.9861749707454420 -07\n'
b' 4 0 4 -6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2193692495097233 -07 -0.8959173003201546 -07\n'
b' 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000000000000000 +00 0.1017891898227051 -03\n'
b' 2 0 3 -5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4236543085970792 -07 -0.8775084424897674 -08\n'
b' 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000000000000000 +00 0.4702795245810685 -04\n'
b' 2 0 3 -5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.5710471800210820 -09 -0.1800837750117577 -08\n'
b' 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000000000000000 +00 -0.5421827377115325 -06\n'
b' 2 0 3 -5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.7074507338012408 -10 0.1742474656298139 -10\n'
b' 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000000000000000 +00 -0.2508633795522544 -07\n'
b' 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000000000000000 +00 0.4575014479216901 -09\n'
b' 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000000000000000 +00 0.5208591612817609 -11\n'
b' 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000000000000000 +00 -0.1737141639583644 -12'

How to limit THREE.TransformControls to have only positive values for scale

Is it possible to for the scale gizmo (THREE.TransformControls) to have only positive values ?
Negative values causes the model to turn inside-out.
I found it: goto TransformControls.js and
replace
var newScaleX = oldScale.x * ( 1 + point.x / oldScale.x );
var newScaleY = oldScale.y * ( 1 + point.y / oldScale.y );
var newScaleZ = oldScale.z * ( 1 + point.z / oldScale.z );
point.applyMatrix4( tempMatrix.getInverse( worldRotationMatrix ) );
if ( scope.axis === "X" ) scope.object.scale.x = newScaleX;
if ( scope.axis === "Y" ) scope.object.scale.y = newScaleY;
if ( scope.axis === "Z" ) scope.object.scale.z = newScaleZ;
with
var newScaleX = oldScale.x * ( 1 + point.x / oldScale.x );
var newScaleY = oldScale.y * ( 1 + point.y / oldScale.y );
var newScaleZ = oldScale.z * ( 1 + point.z / oldScale.z );
point.applyMatrix4( tempMatrix.getInverse( worldRotationMatrix ) );
if (newScaleX>0)
if ( scope.axis === "X" ) scope.object.scale.x = newScaleX;
if (newScaleY>0)
if ( scope.axis === "Y" ) scope.object.scale.y = newScaleY;
if (newScaleZ>0)
if ( scope.axis === "Z" ) scope.object.scale.z = newScaleZ;

Convert to Laravel Query

I have query for query data. That is document.
"SELECT
zk_z_hako * CASE WHEN zk_n_iri> 0 THEN zk_n_iri ELSE 1 END
+ zk_z_bara
- ifnull(
sum(
ns_hako
* CASE WHEN zk_n_iri> 0 THEN zk_n_iri ELSE 1 END
* CASE WHEN ns_tr_kbn in (0,6) OR ( ns_tr_kbn = 1 AND ns_ns_kbn = 7) THEN 1
WHEN ns_tr_kbn in (1,7) THEN (-1)
ELSE 0
END
+ ns_bara
* CASE WHEN ns_tr_kbn in (0,6) OR ( ns_tr_kbn = 1 AND ns_ns_kbn = 7) THEN 1
WHEN ns_tr_kbn in (1,7) THEN (-1)
ELSE 0
END )
,0 ) AS TOTAL_BARA
FROM t_table1
LEFT JOIN t_table2
ON ns_kno = zk_kno
AND ns_show_flg = 0
AND ns_ymd > 'Date param'
WHERE zk_kno = Value param;
So I am not a master of Laravel. Now I need to convert this query for work with laravel. Anyone can help me?
And i have to try this query.
$squery = 'zk_z_hako * CASE WHEN zk_n_iri> 0 THEN zk_n_iri ELSE 1 END
+ zk_z_bara
ifnull(
sum(
ns_hako
* CASE WHEN zk_n_iri> 0 THEN zk_n_iri ELSE 1 END
* CASE WHEN ns_tr_kbn in (0,6) OR ( ns_tr_kbn = 1 AND ns_ns_kbn = 7) THEN 1
WHEN ns_tr_kbn in (1,7) THEN (-1)
ELSE 0
END
+ ns_bara
* CASE WHEN ns_tr_kbn in (0,6) OR ( ns_tr_kbn = 1 AND ns_ns_kbn = 7) THEN 1
WHEN ns_tr_kbn in (1,7) THEN (-1)
ELSE 0
END )
,0 ) AS TOTAL_BARA ';
$param1= '20160310';
$param2= '1972640100';
$results = DB::table('table1')
->select($squery)
->leftJoin('table2', function($join) use ($param1)
{
$join->on('table1.ns_kno', '=', 'table2.zk_kno');
$join->on('table1.ns_show_flg', '=', DB::raw(0));
$join->on('ns_ymd','>',DB::raw("'".$param1."'"));
})
->where('zk_kno', DB::raw($param2))
->toSql()
But it's return sql
"select `zk_z_hako` as `CASE` from `t_zaikmst` left join `t_nsyutrn` on `t_nsyutrn`.`ns_kno` = `t_zaikmst`.`zk_kno` and `t_nsyutrn`.`ns_show_flg` = 0 and `ns_ymd` > '20160310' where `zk_kno` = 1972640100"
i don't sure it true.
If you want to make custom select than you need to use raw queries as select parameter like this:
->select(\DB::raw($squery))

Resources